1- Write a class called MedicalStaff that is aPerson (the class that you wrote in last lab). A MedicalStaff hasspecialty (i.e. Orthopedic, cardiology, etc.).
2- Then write two classes:
Doctor class has office visit fee.
Nurse class has title (i.e. RN, NP, etc.)
Both classes inherit from MedicalStaff.
Be sure these are all complete classes, including toStringmethod.
3- Write a tester to test these classes andtheir methods, by creating an array or ArrayList ofPerson and adding different kinds of objects(MedicalStaff, Doctor, Nurse) to it.
Now that you know polymorphism, you don't need to create specificreferences for each object.
4- Print the list of Person items by callingtoString method in a for-each loop.
The Person class was,
public class Person { // Decalring super class//
private String name; // attributes
private int birthYear;
public Person(String n, int y) {
this.name = n;
this.birthYear = y;
}
public Person() {
name = \"\";
birthYear = 0;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getbirthYear() {
return birthYear;
}
public void setbirthYear(int birthYear) {
this.birthYear = birthYear;
}
public String toString() {
return \"Person [name=\" + name + \", birthYear=\" + birthYear +\"]\";
}
}