Programming Assignment 7
Due April 19, 2012
Send your source code to (with Subject: A7-Sp12 cmp326 Firstname.Lastname)
Write a class named Employee whose objects are records for employees. Derive this class from
the class Person (given in Listing 8.1). An employee record inherits an employee’s name from
the class Person. In addition, an employee record contains an annual salary (salary) represented
as a single value of type double, a hire year (hireYear) as a single value of type int, and an
employee identification number (eID) that is a value of type String.
Write a default constructor that assigns “No Name Yet”, 10000.0, 2011, “999-99-9999”
by calling overloaded constructor Employee(String name, double salary, int hireYear,
Write accessor methods and mutator methods, as well as an equals() method to test
equality of two employee objects.
Write a program EmployeeTest to test Employee class. EmployeeTest iterates until user
wants to quit the program. EmployeeTest asks the user enter data for an employee and
displays information about the employee created.
Write a class named Doctor whose objects are records for a clinic’s medical doctors. Derive this
class from the class Person given in Listing 8.1. A Doctor record has the doctor’s name (name)—
defined in the class Person—a specialty (specialty) as a string (for example Pediatrician, Surgeon,
Family Doc, and so on), and an office-visit fee (fee) (type double).
Write at least two constructors (including default constructor), accessor/mutator methods,
and an equals() method as well. Write a driver program to test all the methods of the
Write two classes, Patient and Billing, whose objects 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 class has a Patient object and a
Doctor object as instance variables. Billing class also has billAmount (in double) as an instance
variable for calculating total income from Billing records. Billing class implements
Comparable<T> interface to sort an array of the Billing objects into ascending order (according
to the natural ordering of its billAmount).
For each class, write at least two constructors (including default constructor),
accessor/mutator methods, and an equals method as well.
Write a driver program PatientTest to test Patient class.
Write a test program BillingTest that creates at least three patients, at least three doctors,
and at least three Billing records and then displays the total income from the Billing
records. Create an array of Billing objects, and sort the array by Arrays.sort() method.
Then print out the Billing records in the decreasing order of billAmount. Each Billing
record has data about doctor and patient in addition to the billAmount.
Develop a JFrame based GUI that can do temperature and distance conversion.
Design an extension of JPanel intended for calculating conversions between distances in feet
and in meters. The JPanel should contain two JTextFields, one displaying the message
"Enter feet here" and the other "Enter meters here". Give the JPanel a flow layout manager,
and add the two text fields.
Design a similar version of JPanel intended for calculating conversions between
temperatures in Celsius and in Fahrenheit. The texts should be "Enter Celsius here" and
"Enter Fahrenheit here.
Design an extension of JFrame to contain the two JPanels you made. Give it a suitable size,
set the close box to exit the program, and give it an appropriate title. Also provide it with a
grid layout with 2 rows and 1 column, and add instances of the two JPanels.
Create a class with a main to instantiate the JFrame of item 3 above, and display it.
So far your code provides a GUI to display, but it does not handle events. Now provide
ActionListeners for each of the JTextFields of items 1 and 2 above. If one enters a
Fahrenheit temperature in the Fahrenheit field, 212 for instance, and hits 'return' the display
in that field should change to "Fahrenheit: 212" and in the Celsius field it should change to
"Celsius: 100". Similarly for the feet and meters fields. In order to do this you need to know
how to calculate conversions. The following are the formulas for conversion.
meters = feet * 0.3048
feet = meters * 3.2808399
fahrenheit = (celsius * 1.8) + 32
celsius = (fahrenheit - 32)/1.8
Study ATM application development process (optional)
In this optional programming assignment, you will study design and implementation of
the automated teller machine (ATM) software system based on object-oriented design
(OOD) process using the universal modeling language (UML).
Design and implementation processes of the ATM are explained in two chapters of the
2nd reference book listed on our course web site (Deitel’s Java- How to Program).
The user interface implemented is command line interface (CLI) although explanation of
the ATM design process is based on a virtual ATM GUI.
ATM project source code and two PDF files (ATMOODesign, ATMOOImplement) are
uploaded in a zip folder named ATMProject.zip on our course web site.
Do not send the source code of the ATM project to me by email.
We may study more advanced GUI based ATM project based on OOD using UML if time
permits (and may be assigned as an optional project). To understand the GUI based ATM, you
need to practice optional ATM example project given in this Assignment7.