Java Reference
In-Depth Information
public Person()
{...}
public Person(String theName)
{...}
public Person(Person theObject)
{...}
public String getName()
{...}
public void setName(String theName)
{...}
public String toString()
{...}
public boolean equals(Object other)
{...}
}
7. Give the definition of two classes, Patient and Billing , whose objects are records
for a clinic. Patient will be derived from the class Person given in Programming
Project 7.6 . A Patient record has the patient's name (inherited from the class
Person ) and primary physician of type Doctor defined in Programming Project 7.5
A Billing object will contain a Patient object, a Doctor object, and an amount
due of type double . Be sure your classes have a reasonable complement of construc-
tors, accessor, and mutator methods, and suitably defined equals and toString
methods. First write a driver program to test all your methods, then write a test pro-
gram that creates at least two patients, at least two doctors, and at least two Billing
records, and then prints out the total income from the Billing records.
8. Programming Project 4.10 required adding an instance variable to the Pet class
defined in Display 4.15 to indicate if the pet is a dog or cat. A better organiza-
tion is to define Pet as a superclass of the Dog and Cat classes. This organization
eliminates the need for an instance variable to indicate the type of the pet. Do
or redo Programming Project 4.10 with inheritance. The acepromazine() and
carprofen() methods should be defined in the Pet class to simply return 0. Over-
ride both methods in the Dog and Cat classes to calculate the correct dosage. Write
a main method with appropriate tests to exercise the changes.
Search WWH ::




Custom Search