Define two classes, Patient and Billing, whose objecyts are records for a clinic
ID: 3642148 • Letter: D
Question
Define two classes, Patient and Billing, whose objecyts are records for a clinic. Derive Patient from the class Person given in Listing 8.1. A Patient record has the patient's 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 ( from Project 4). 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.The Person Class
public class Person
{
String name;
public Person( )
{
name = "No name yet";
}
public Person(String initialName)
{
name = initialName;
}
public void setName(String newName)
{
name = newName;
}
public String getName( )
{
return name;
}
public void writeOutput( )
{
System.out.println("Name: " + name);
}
public boolean hasSameName(Person otherPerson)
{
return this.name.equalsIgnoreCase(otherPerson.name);
}
}
My Doctor Class (probably is not right)
import java.util.Date;
public class Doctor extends Person{
String specialty;
Date today;
double salary;
double visitFee;
public Doctor() {
specialty="none";
today=new Date();
salary=0;
visitFee=0;
}
public Doctor(String theName, Date theDate, double theSalary,
String theSpecialty, double theVisitFee) {
today = theDate;
salary=theSalary;
specialty=theSpecialty;
visitFee=theVisitFee;
}
public Doctor(Doctor orig) {
today=orig.today;
salary=orig.salary;
specialty=orig.specialty;
visitFee=orig.visitFee;
}
public String getSpecialty() {
return specialty;
}
public void setSpecialty(String theSpecialty){
specialty=theSpecialty;
}
public double getVisitFee(){
return visitFee;
}
public double setVisitFee(double theVisitFee) {
return visitFee;
}
public boolean equals (Doctor other) {
return specialty.equals(other.specialty) && today == other.today && salary == other.salary && getName().equals(other.getName()) && visitFee == other.visitFee;
}
public String toString() {
return getName() +" is a " + specialty + ", his/her fee per visit is " + visitFee + ".";
}
}
Explanation / Answer
Need the answer to this assignment? Need help with your computer programming homework? Email renae04_05@yahoo.com I have answers to the homework. Will respond to emails in a timely manner and commented code so you can follow my work. Serious inquiries only!
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.