For this task you will create a Subject class, whose instances will represent the subjects for study at a university. A
Posted: Fri Apr 29, 2022 8:04 am
For this task you will create a Subject class, whose instances
will represent the subjects for study at a university. A subject
will have a name, just a String, and a subject code, which is a
7-
character String (Example BIS2004). The first three characters of a
subject code are alphabetic and the last 4 are numeric. The first
three characters define the subject's discipline area. A subject
code must be unique.
You will also write a TestSubject class to test the use of your
Subject class. In particular this will maintain an array of
subjects. In order to manage the uniqueness of the subject codes,
your program will need to display information about existing
subject codes as well as checking that any new subject code
supplied by the user is not the same as any existing subject
code.
In addition to the below, you needed to include the algorithm and
UML diagram for this task.
The following state and functionality should be provided for the
Subject class:
1) Two data fields that will hold the subject’s name and the
7-character subject_code.
2) A constructor will allow a name and a new, validated subject
code to be provided when a new subject is created.
3) Getters will provide access to the above two attributes.
4) A toString method will return a string containing the subject
code and subject name.
To assist with managing subject codes and their uniqueness you will
provide the Subject class with some more methods as follows:
1) An isValidCode method will accept a string that is a possible
new subject code, and return a boolean indicating whether it
satisfies the structural requirements for a subject code.
2) A codeExists method will accept an array of Subject objects and
a possible new subject code. It will return a boolean indicating
whether that code has already been allocated to one of the subjects
in the array.
3) A sortDisciplines method will accept an array of Subjects
objects. It will return the sorted array of subjects in
alphabetically order by Subject_code.
Your TestSubject program will perform the following sequence of
actions, using good design techniques such as in the appropriate
use of methods:
1) Start your test program by creating 3 of the below subjects as
new instances. (The code should check isValidCode and codeExists
method before saving the instances into data structure)
a. Subject Name = Object-Oriented Programming. Subject_code =
BIS2004
b. Subject Name = Introduction to Programming. Subject_code =
BIS1003
c. Subject Name = Data and Information Management. Subject_code =
BIS1002
2) Whenever you create new subject, the values should get stored in
appropriate data structure (like ArrayList)
3) Now if the user wishes to add new subjects, the discipline areas
of existing subjects should be displayed in alphabetically order.
And when user tries to add new subject, the code checks for
isValidCode() to make sure it satisfies the structural requirements
for a subject code and then checks for codeExists method to make
the subject code is not exist in the data structure before.
4) Each subject code entered by the user should be checked. The
user can enter any new subjects in that discipline (or indeed in
other disciplines). The user should be given the choice of
repeating the processing for totally 10 subjects. (means totally 10
subject codes and names should get added to the data structure
after validation)
5) When the user has finished adding subjects after validation,
call toString method to display 10 subject details.
Note:
You may use an ArrayList to implement an array if you prefer and it
is appropriate.
Include algorithm and UML diagram, Thank You!!!!!
will represent the subjects for study at a university. A subject
will have a name, just a String, and a subject code, which is a
7-
character String (Example BIS2004). The first three characters of a
subject code are alphabetic and the last 4 are numeric. The first
three characters define the subject's discipline area. A subject
code must be unique.
You will also write a TestSubject class to test the use of your
Subject class. In particular this will maintain an array of
subjects. In order to manage the uniqueness of the subject codes,
your program will need to display information about existing
subject codes as well as checking that any new subject code
supplied by the user is not the same as any existing subject
code.
In addition to the below, you needed to include the algorithm and
UML diagram for this task.
The following state and functionality should be provided for the
Subject class:
1) Two data fields that will hold the subject’s name and the
7-character subject_code.
2) A constructor will allow a name and a new, validated subject
code to be provided when a new subject is created.
3) Getters will provide access to the above two attributes.
4) A toString method will return a string containing the subject
code and subject name.
To assist with managing subject codes and their uniqueness you will
provide the Subject class with some more methods as follows:
1) An isValidCode method will accept a string that is a possible
new subject code, and return a boolean indicating whether it
satisfies the structural requirements for a subject code.
2) A codeExists method will accept an array of Subject objects and
a possible new subject code. It will return a boolean indicating
whether that code has already been allocated to one of the subjects
in the array.
3) A sortDisciplines method will accept an array of Subjects
objects. It will return the sorted array of subjects in
alphabetically order by Subject_code.
Your TestSubject program will perform the following sequence of
actions, using good design techniques such as in the appropriate
use of methods:
1) Start your test program by creating 3 of the below subjects as
new instances. (The code should check isValidCode and codeExists
method before saving the instances into data structure)
a. Subject Name = Object-Oriented Programming. Subject_code =
BIS2004
b. Subject Name = Introduction to Programming. Subject_code =
BIS1003
c. Subject Name = Data and Information Management. Subject_code =
BIS1002
2) Whenever you create new subject, the values should get stored in
appropriate data structure (like ArrayList)
3) Now if the user wishes to add new subjects, the discipline areas
of existing subjects should be displayed in alphabetically order.
And when user tries to add new subject, the code checks for
isValidCode() to make sure it satisfies the structural requirements
for a subject code and then checks for codeExists method to make
the subject code is not exist in the data structure before.
4) Each subject code entered by the user should be checked. The
user can enter any new subjects in that discipline (or indeed in
other disciplines). The user should be given the choice of
repeating the processing for totally 10 subjects. (means totally 10
subject codes and names should get added to the data structure
after validation)
5) When the user has finished adding subjects after validation,
call toString method to display 10 subject details.
Note:
You may use an ArrayList to implement an array if you prefer and it
is appropriate.
Include algorithm and UML diagram, Thank You!!!!!