Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem Design and implement a class hierarchy for the types of people at a University: - a Person can be Faculty, Staff, or a Student;
Problem
Design and implement a class hierarchy for the types of people at a University:
- a Person can be Faculty, Staff, or a Student;
- a Person has a name and is abstract, with the abstract method int getParkingFees()
- a Faculty member has a faculty they belong to i.e. Faculty of Science, and a parking fee of 6 dollars daily
- a Staff member has a department they belong to i.e. Building Maintenance, and a parking fee of 5 dollars daily
- a Student has a program of study (eg BCS degree) and a parking fee of 3 dollars daily
The classes described above should have the usual constructors (default and parameterized), get (accessor) and set (mutator) methods for each attribute, and a toString method.
Note: In the tester program create an array of object for testing purposes.
Child classes should call parent methods whenever possible to minimize code duplication.
The driver program must test all the methods in each of the classes. Include comments in your output to describe what you are testing, for example System.out.println(testing Faculty toString, accessor and mutator);. Print out some blank lines in the output to make it easier to read and understand what is being output.
Note: In the tester/driver program create an array of object for testing purposes, containing at least 2 persons of each type (Students, Faculty, Staff). Using polymorphism display the details of each person in the array (use a loop and call the toString for each object, as well as the charge for parking).
Youll need perform a cast to access methods defined in the child classes. Show that the code works by producing suitable outputs
Assignment Submission:
Submit a print-out of each class file, the driver file and a sample of the output.
Marking Checklist
1. Does EACH class have all the usual methods?
2. Are all methods in EACH class tested, including child objects calling inherited parent methods?
3. Does the child class call the parents constructor?
4. Does the child class override the parents toString?
5. Does the output produced have lots of comments explaining what is being output?
6. Does each class, and the output, have blank lines and appropriate indenting to make them more readable?
(I want this code written on the computer in dr java because someone sent me written on a note book with a very bad handwriting)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started