For todays lab you will be implementing two of your own inheritance hierarchies. It is a smaller/simpler lab, with an earlier deadline. The expectation being that you will also use this time to start your Project #1.
Part 1
Implement a superclass Person.
Make two classes, Student and Instructor, that inherit from Person.
- A person has a name and a year of birth (2 points)
- A student has a major (2 points)
- An instructor has a salary (2 points)
Write
- The class declarations (1 point each x 3 = 3 points)
- The appropriate constructors (2 points each for sub x 1, 1 point for super= 5 points) o Make one for each class that initializes all the data and utilizes the Super() constructor appropriately.
- That is, the student and instructor constructors will call the super constructor with the appropriate data to initialize the persons instance variables.
- For example, the student and instructor constructors will need the information necessary (parameters) that includes person information
- The (appropriate and overridden) toString methods for all classes. (3 points) o For each class implementation of toString, use (extend) behavior from each super class toStrings method in order to avoid duplicate code (Negative points for duplicate code)!
- Getters and Setters (Negative points if done wrong)
Supply a single test program that tests these classes and methods, including the constructors. (2 points)
Part 2
- Make a class Employee with a name and salary. (2 points)
- Make a class Manager that extends Employee.
- Add an instance variable for type Manager, named department, of type String.
(4 points)
- Make a class Executive inherit from Manager.
- An Executive has a String that represents their office location. (3 points)
- Implement the appropriate constructors (2 points each for sub x 1, 1 point for super= 5 points) o Make one for each class that initializes all the data and utilizes the super() constructor appropriately.
- That is, the Manager constructor will call the super constructor with the appropriate data to initialize the Employees instance variables. Same for executive.
- Supply appropriate toString methods for all classes. (4 points) o For each implementation of toString, use (extend) behavior from each super class toStrings method in order to avoid duplicate code. (Negative points if not done)
- For example, override the method toString to print the Managers name, department, and salary.
- The Executive toString will include Manager and Employee information as well.
- Include Getters and Setters (Negative points if done wrong)
Supply a single test program that tests these classes and methods, including the constructors. (2 points)
Tips and Additional Requirements
- You do not have to test your getters and setters.
- You do have to test your constructors. You can do that by
- Creating the object
- Testing that the instance variables were set correctly by the constructor. You can do this using the getters and setters.
You need not use the automated/generated toString text that Eclipse provides. You can change it in your various classes to be something more aesthetically pleasing, for example,
I am a student majoring in X. I am also a Person whose name is A and was born in B.
All we will be checking for is that you output all the information at each level and use the super call appropriately.

![[Solved] CSE271-Lab 5-implement two of your own inheritance hierarchies](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] CSE271-Lab9 -a graphical application that produces a restaurant bill](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.