Question: Create a sub class named Administrator, which is also a kind of employee in a hospital. Please add the following structures to Administrator class. Identifiers
Create a sub class named Administrator, which is also a kind of employee in a hospital. Please add the following structures to Administrator class.
|
| Identifiers for field or methods | Data type for field or parameters for methods | Additional requirement |
| Field added | department | String |
|
|
|
|
|
|
| Methods to be handled | Administrator | Parameter:empName, empNumber,dept | The method Administrator is a constructor. |
|
| setDepartment |
|
|
|
| getDepartment |
|
|
|
| toString |
| Returns a description of this administrator as a string |
|
| administrate |
| Prints a message appropriate for this administrator |
Then add statements in the example main driver file(Hospital.java) and exercise the main class. You may remove the statements for the objects of Doctor and Nurse in the main driver class because they were implemented in the examples. The main driving class only creates two objects, one is an Employee(Vito), the second one is an Administrator(Jason).
When you run your program, you may see the result like this:
> run Hospital
Vito 123
Jason 404 HR department
Vito works for the hospital.
Jason is a HR department Administrator.
Please use extends, super, and protected in the appropriate places to show inheritance. You need three files to work on the project, HospitalEmployee.java(no need to change from the example), Administrator.java(create this new file), and Hospital.java(add some statements to it).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
