Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Billing Record with Exception The following Person, Patient, Doctor and Billing Classes are given. A possible sample output is also given. The Main Class is

Billing Record with Exception

The following Person, Patient, Doctor and Billing Classes are given. A possible sample output is also given. The Main Class is not given. By using the given classes, create a main class that will match the possible sample output. The question does not specify if the given classes need to be adjusted, but if needed then do so accordingly.

Sample Output:

Enter number of doctors in the facility: 2

Enter number of patients in the facility: 5

-----------------------------

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

Patient 3

Enter Patient's name: Mark Kapur

Enter Patient ID: 6789

Patient 4

Enter Patient's name: Lilian Snyder

Enter Patient ID: 7890

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: 3

Enter Doctor index: 0

Do you want to set another appointment? (y/n)y

Enter Patient index: 4

Enter Doctor index: 1

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: 1

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 $1622.94

------------------------------------

Person Class:

/* * 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. */ public class Person { protected String name; public Person() { name = ""; } public Person(String name) { this.name = name; } public String getName() { return name; } public boolean hasSameName(Person secondPerson) { if(name.equalsIgnoreCase(secondPerson.getName())) return true; else return false; } public void display() { System.out.printf("%-20s %s ", "Name", name); } }

Patient Class:

/* * Drive Patient from the class Person. A patient record has the Patient's name, and an identification number. */ public class Patient extends Person{ protected int id; public Patient(String name, int id) { super(name); this.id = id; } public void display() { super.display(); System.out.printf("%-20s %d ","ID", id); } public int getId() { return id; } public boolean equals(Patient second) { if(super.hasSameName(second) && id == second.getId()) return true; else return false; } }

Doctor Class:

/* * 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. */ public class Doctor extends Person{ //String name: from super class protected String specialty; protected double visitFee; protected double income; public Doctor(String name, String specialty, double visitFee) { super(name); this.specialty = specialty; this.visitFee = visitFee; this.income = 0; } public String getSpecialty() { return specialty; } public double getVisitFee() { return visitFee; } 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("------------------------------------"); } public void oneLineDisplay() { System.out.printf("%-20s %-20s $%.2f ", name, specialty, visitFee); } public boolean equals(Doctor secondDoctor) { boolean nameStatus = name.equalsIgnoreCase(secondDoctor.getName()); boolean specialtyStatus = specialty.equalsIgnoreCase(secondDoctor.getSpecialty()); boolean visitFeeStatus = visitFee == secondDoctor.getVisitFee(); if(nameStatus && specialtyStatus && visitFeeStatus) return true; else return false; } }

Billing Class:

/* * 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. */ public class Billing{ private Doctor doctor; private Patient patient; public Billing(String dname, String specialty, double visitFee, String pname, int id) { doctor = new Doctor(dname, specialty, visitFee); patient = new Patient(pname, id); doctor.income =+ doctor.visitFee; } public Billing(Doctor d, Patient p) { doctor = d; patient = p; doctor.income += doctor.visitFee; } public void display() { System.out.println("-------- Doctor Information --------"); doctor.display(); System.out.println("-------- Pateint Information --------"); patient.display(); System.out.println("---------- Doctor's Income ----------"); } public Doctor getDoctor() { return doctor; } public Patient getPatient() { return patient; } public boolean equals(Billing second) { if(doctor.equals(second.getDoctor()) && patient.equals(second.getPatient())) return true; else return false; } }

Main Class:

Not Given

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Differentiate the function. H(z) = lna 2 - z 2 /a 2 + z 2

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago