1- Write a class called MedicalStaff that is a Person (the class that you wrote in...

90.2K

Verified Solution

Question

Programming

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 +\"]\";
}

}

Answer & Explanation Solved by verified expert
4.2 Ratings (850 Votes)
Code is Given BelowMedicalStaffjavacreating MedicalStaff classpublic class MedicalStaff extends Person declaring variable private String specialty declaring parameter constructor public MedicalStaffString n int y String specialty supern ycalling superconstructor thisspecialty specialty public MedicalStaff super thisspecialty getter and setter method public String getSpecialty return specialty public void    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students