Question: Define two classes, Patient and Billing, whose objects are records for a clinic. A Patient record has the patient s name ( defined in the
Define two classes, Patient and Billing, whose objects are records for a clinic. A Patient record has the patients name defined in the class Person and identification number use the type String A Billing object will contain a Patient object and a Doctor object. Give your classes a reasonable complement of constructors and accessor methods, and an equals method as well. First write a driver program to test all your methods, then write a test program that creates at least two patients, at least two doctors, and at least two Billing records and then displays the total income from the Billing records. Below is what I have so far but I get an error code in the doctor class about the super display. Could someone fix what I have wrong and run the program to work properly?
class Person
private String name;
public PersonString name
this.name name;
public String getName
return name;
public void setNameString name
this.name name;
public boolean hasSameNamePerson other
return this.name.equalsothername;
class Doctor extends Person
private String specialty;
private double visitFee;
private double income ;
public DoctorString name, String specialty, double visitFee
supername;
this.specialty specialty;
this.visitFee visitFee;
public String getSpecialty
return specialty;
public void setSpecialtyString specialty
this.specialty specialty;
public double getVisitFee
return visitFee;
public void setVisitFeedouble visitFee
this.visitFee visitFee;
public double getIncome
return income;
public void addIncomedouble amount
income amount;
public boolean equalsDoctor other
return super.hasSameNameother && this.specialty.equalsotherspecialty && this.visitFee other.visitFee;
public void display
super.display;
System.out.printfs s
"Specialty", specialty;
System.out.printfs $f
"Office Visit Fee", visitFee;
System.out.printfs $f
"Total Income", income;
System.out.println;
class Patient extends Person
private int patientID;
public PatientString name, int patientID
supername;
this.patientID patientID;
public int getPatientID
return patientID;
public void setPatientIDint patientID
this.patientID patientID;
public boolean equalsPatient other
return super.hasSameNameother && this.patientID other.patientID;
public class BillingRecordDemo
public static void mainString args
Scanner input new ScannerSystemin;
System.out.printlnEnter number of doctors in the facility: ;
int numDoctors input.nextInt;
Doctor docArray new DoctornumDoctors;
System.out.printlnEnter number of patients in the facility: ;
int numPatients input.nextInt;
Patient patArray new PatientnumPatients;
for int i ; i numDoctors; i
System.out.println;
System.out.printlnDoctor i ;
input.nextLine; Consume newline
System.out.printlnEnter doctor's name: ;
String doctorName input.nextLine;
System.out.printlnEnter Specialty: ;
String specialty input.nextLine;
System.out.printlnEnter office visit fee: ;
double visitFee input.nextDouble;
docArrayi new DoctordoctorName specialty, visitFee;
for int i ; i numPatients; i
System.out.println;
System.out.printlnPatient i;
input.nextLine; Consume newline
System.out.printlnEnter Patient's name: ;
String patientName input.nextLine;
System.out.printlnEnter Patient ID: ;
int patientID input.nextInt;
patArrayi new PatientpatientName patientID;
char response;
do
System.out.printlnEnter Patient index: ;
int patientIndex input.nextInt;
System.out.printlnEnter Doctor index: ;
int doctorIndex input.nextInt;
docArraydoctorIndexaddIncomedocArraydoctorIndexgetVisitFee;
System.out.printlnDo you want to set another appointment? yn;
response input.nextcharAt;
while response y response Y;
for Doctor doctor : docArray
doctor.display;
System.out.printlnDo you want to check Doctor Object class: yn;
char respond input.nextcharAt;
if respond y respond Y
checkObjectClassDoctorinput docArray;
System.out.printlnDo you want to check Patient object class: yn;
respond input.nextcharAt;
if respond y respond Y
checkObjectClassPatientinput patArray;
public static void checkObjectClassDoctorScanner input, Doctor d
System.out.printlnEnter Doctor's name: ;
String name input.next;
input.nextLine; Consume newline
System.out.printlnEnter Doctor's specialty: ;
StSystem.out.printlnEnter office visit fee: ;
double fee input.nextDouble;
Doctor doc new Doctorname specialty, fee;
if dhasSameNamedoc
System.out.printlnSame name";
else
System.out.printlnNot the same name";
if dequalsdoc
System.out.printlnSame doctor";
else
System.out.printlnNot the same doctor";
public static void checkObjectClassPatientScanner input, patient p
System.out.printlnEnter Patient's Name: ;
String name input.next;
input.nextLine;
System.out.printlnEnter Patient's ID:;
int id input.nextInt;
Patient pat new Patientname id;
if phasSameNamepat
System.out.printlnSame name";
else
System.out.printlnNot the same name";
if pequalspat
System.out.printlnSame patient";
else
System.out.printlnNot the same patient";
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
