You are to write THREE SEPARATE PROGRAMS! 1. To define the superclass 2. To defi
ID: 3625329 • Letter: Y
Question
You are to write THREE SEPARATE PROGRAMS!
1. To define the superclass
2. To define a subclass based on the superclass
3. To write a Test program that creates objects from the subclass
Please write and compile the programs to see that they work separately
And PASTE THEM INTO ONE (ONE ONE ONE ONE) WORD FILE
WORD FILE WORD FILE WORD FILE WORD FILE
For grading. Clearl document each program
If you don't follow these directions, I won't grade your project
I will run each program separately to see if they all work
You will only get credit for programs that work
Super Class Name: Doctor
Data: addr: String
medicalSchool: String
specialty: String
Methods: getPatients(): int
setPatients(int): void
Constructor: Doctor()
Subclass Name: Surgeon
Add to subclass
Data: employee: String
Method: getPatients(): int
Object from Subclass: newSurgeon
Explanation / Answer
public class Doctor { private String addr; private String medicalSchool; private String specialty; private int patients; public class Doctor() { addr=""; medicalSchool=""; specialty=""; patients=0; } public void setPatients(int ill) { patients=ill; } //right here i don't know exactly how your trying to return the patients, if you need //something in the parameter than add another instance variable public int getPatients() { return patients; } } .... .... ... public class Surgeon extends Doctor { private String employee; private int patients; public Surgeon(String name) { employee=name; patients=0; } public int getPatients() { return patients; } //i don't know if you want to add other methods like setEmployee(String name) or //other methods. .. . . . . public class testRunner{ public static void main(String[] args) { Doctor fred=new Doctor(); Surgeon newSurgeon=new Surgeon("David"); }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.