Question
Define a class Person that holds person's name and appropriate constructors, get/set methods, display and hasSameName methods. hasSameName method will return true if two objects
Define a class Person that holds person's name and appropriate constructors, get/set methods, display and hasSameName methods. hasSameName method will return true if two objects of data type Person have the same name. Then define a class named Doctor whose objects are records for a clinic's doctors. Drive this class from the class Person. A Doctor record has doctor's name, a specialty, and office visit fee. Give your class a reasonable complement of constructors and get/set methods, and an equals method as well. The equals method returns true if two doctor records are the same. Name this class BillingRecordDemo. Drive Patient form the class Person. A patient record has the Patient's name, and an identification number. A Billing object will contain a Patient object and a Doctor object. Give your class a reasonable complement of constructors, get/set methods, display and an equals method. Sample run:
Enter number of doctors in the facility: 2 Enter number of patients in the facility: 3 ----------------------------- Create Doctor Array: ----------------------------- Doctor 1 Enter doctor's name: Garry Allen Enter Specialty: Family Medicine Enter office visit fee: 180.65 Doctor 2 Enter doctor's name: Sarah Adler Enter Specialty: Cardiology Enter office visit fee: 540.98 ----------------------------- Create Patient Array: ----------------------------- Patient 0 Enter Patient's name: Bruce Ammar Enter Patient ID: 1234 Patient 1 Enter Patient's name: Mike Anderson Enter Patient ID: 2345 Patient 2 Enter Patient's name: Jenna Baily Enter Patient ID: 5678 Enter Patient index: 0 Enter Doctor index: 0 Do you want to set another appointment? (y/n) y Enter Patient index: 0 Enter Doctor index: 1 Do you want to set another appointment? (y/n) y Enter Patient index: 1 Enter Doctor index: 0 Do you want to set another appointment? (y/n) y Enter Patient index: 2 Enter Doctor index: 0 Do you want to set another appointment? (y/n) y Enter Patient index: 2 Enter Doctor index: 1 Do you want to set another appointment? (y/n) n Name Garry Allen Specialty Family Medicine Office Visit Fee $180.65 Total Income $541.95 ------------------------------------ Name Sarah Adler Specialty Cardiology Office Visit Fee $540.98 Total Income $1081.96 ------------------------------------ Do you want check Doctor Object class: (y/n) y Enter Doctor's name: Garry Allen Enter Doctor's specialty: Family Medicine Enter office visit fee: 180.65 Same name Same doctor Do you want check Patient object class: (y/n) y Enter Patient's name: Bruce Ammar Enter Patients's ID: 4567 Same name Not the same patient
Note: In Doctor class use the following display method:
public void display() { super.display(); System.out.printf("%-20s %s ", "Specialty", specialty); System.out.printf("%-20s $%.2f ", "Office Visit Fee", visitFee); System.out.printf("%-20s $%.2f ", "Total Income", income); System.out.println("------------------------------------"); }
Use the following template for your Main application Java class.
public class Main{ public static void main(String[] args) { //complete this part //check object classes System.out.println("Do you want check Doctor Object class: (y/n"); char respond = input.nextLine().charAt(0); if(respond == 'y' || respond == 'Y') checkObjectClassDoctor(input , docArray[0]); System.out.println("Do you want check Patient object class: (y/n"); respond = input.nextLine().charAt(0); if(respond == 'y' || respond == 'Y') checkObjectClassPatient(input , patArray[0]); } public static void checkObjectClassDoctor(Scanner input , Doctor d) { System.out.println("Enter Doctor's name: "); String name = input.nextLine(); System.out.println("Enter Doctor's specialty: "); String specialty = input.nextLine(); System.out.println("Enter office visit fee: "); double fee = input.nextDouble(); Doctor doc = new Doctor(name, specialty, fee); if(d.hasSameName(doc)) System.out.println("Same name"); else System.out.println("Not have same name"); if(d.equals(doc)) System.out.println("Same doctor"); else System.out.println("Not the same doctor"); } public static void checkObjectClassPatient(Scanner input, Patient p) { System.out.println("Enter Patient's name: "); String name = input.nextLine(); System.out.println("Enter Patients's ID:"); int id = input.nextInt(); Patient pat = new Patient(name, id); if(p.hasSameName(pat)) System.out.println("Same name"); else System.out.println("Not have same name"); if(p.equals(pat)) System.out.println("Same patient"); else System.out.println("Not the same patient"); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started