ITU wants you write some classes for their Personnel Record System. To make it simple, consider only 4 classes: Person, Employee, Instructor and Student. The following figure illustrates the relationship between these 4 classes. The Person class is the parent class of the Employee class and the Student class. The Employee class is the parent class of the Instructor class.
The following are the tasks you need to complete for each of these classes.
1. Create appropriate fields for each class. Necessary fields are listed. Add your own fields if needed. Some fields need to have appropriate constraint. Use your own way to make sure that these constraints are satisfied.
ID: int, starting from 1 and should be unique
Salary: double and should not be negative
o Student (For simplicity, assume that a student has at most 1 teacher)
TeacherID: int. It’s his/her instructor’s ID. 0 if no instructor is given
StudentIDArray: int array. An array of students’ IDs of this instructor. Set the array size to be 10, initially all 0s, assuming an instructor won’t have more than 10 students.
2. All the above fields are private and only accessible through the access methods.
3. A “toString()” method for each class to print out all the available information about the current object. In Person class “toString()” is declared as abstract.
4. A static “findStudents(Person personArray)” method in the Instructor class to fill an instructor object’s students ID array, and the corresponding students’ TeacherID fields. See the test program for better understanding.
5. Person should be declared as abstract class.
6. Provide multiple constructors/methods if needed. Check the test.java program below to see what constructors/methods are necessary and what actions they should do.
7. If a class can use the parent class method and constructor, use “super” to call it to reduce the redundant code.
8. Make sure the test.java program can work with your class.
9. See the sample output below. From this sample output, you’ll know what information you should print out for a specific object.
NOTE: the sample output is not the unique output format of the test program. The real output format depends on how you design the toString() methods in each class. But make sure that your program will print out as much information about each object’s fields as possible, including the inherited fields and the fields defined in its own class.
o There is NO main method in any of these 4 classes
o To make sure ID is unique across the objects, declare a static “LAST_ID” in the Person class.
o Read descriptions in test.java VERY CAREFULLY for better understanding!
Submit your Person.java, Emloyee.java, Student.java and Instructor.java files.