Inheritance Create a class named Person and its two subclasses named Student and Employee. Then create Faculty and Staff as subclasses of Employee. A Person has a name, address, phone number, and email address. Each of these will be String objects. A Student has a class status which will be an int ( 1 for a freshman, 2 for a sophomore, 3 for a junior, or 4 for a senior). An Employee has an office (String), salary(int), and a date hired(String). A Faculty Member has office hours (String) and a rank which will be an int(1 for a Lecturer, 2 for an Assistant Professor, 3 for an Associate Professor, or 4 for a Professor). A Staff member has a title. Each class will have a toString() method to display the name of the class and the person’s name. For a Student, the toString() method will also return the class status (freshman, sophomore, junior, senior), for an Employee, the salary, for a faculty member, the rank (Lecturer, Assistant Professor, Associate Professor, Professor), and for a Staff member, the title. Make sure that the code in all classes in your Person inheritance hierarchy is thoroughly documented. Show how each class relates to any other class in the hierarchy. All methods must have comments. Write a test class named InheritanceDemo that Creates a Person, Student, Employee, Faculty Member, and a Staff Member. Sets values for all properties for a particular object (e.g. for a Student you will give the student a name, address, phone number, email address, and class status). Prints a string representation for each object, i.e invoke their toString() method. Notes: Give all instance variables protected visibility to allow access without setters and getters Use an appropriate constructor for all classes. Make sure that each constructor assigns values for all instance variables of the particular class. You may want to view the videos again, taking note of how the properties for each object get their values. Hard code the data in InheritanceDemo class.
1. Inheritance
Create a class named Person and its two subclasses named Student and Employee. Then create Faculty and Staff as subclasses of Employee.
- A Person has a name, address, phone number, and email address. Each of these will be String objects.
- A Student has a class status which will be an int ( 1 for a freshman, 2 for a sophomore, 3 for a junior, or 4 for a senior).
- An Employee has an office (String), salary(int), and a date hired(String).
- A Faculty Member has office hours (String) and a rank which will be an int(1 for a Lecturer, 2 for an Assistant Professor, 3 for an Associate Professor, or 4 for a Professor).
- A Staff member has a title.
Each class will have a toString() method to display the name of the class and the person’s name. For a Student, the toString() method will also return the class status (freshman, sophomore, junior, senior), for an Employee, the salary, for a faculty member, the rank (Lecturer, Assistant Professor, Associate Professor, Professor), and for a Staff member, the title.
Make sure that the code in all classes in your Person inheritance hierarchy is thoroughly documented. Show how each class relates to any other class in the hierarchy. All methods must have comments.
Write a test class named InheritanceDemo that
- Creates a Person, Student, Employee, Faculty Member, and a Staff Member.
- Sets values for all properties for a particular object (e.g. for a Student you will give the student a name, address, phone number, email address, and class status). Prints a string representation for each object, i.e invoke their toString() method.
Notes:
- Give all instance variables protected visibility to allow access without setters and getters
- Use an appropriate constructor for all classes. Make sure that each constructor assigns values for all instance variables of the particular class. You may want to view the videos again, taking note of how the properties for each object get their values.
- Hard code the data in InheritanceDemo class.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images