Overview
In this project, you are to define a class hierarchy consisting of Person, Employee, and Customer classes and an application that allows the user to load and process a Vector with a mix of Employee and Customer objects. Along the way you must use an abstract class, polymorphism, an abstract method, an overriding version of an inherited method, object conversion and casting, and an interface.
Requirements
In a single source file named App.java
Code an abstract superclass named Person. It must have instance variables for holding last name and first name (both String). Provide a single constructor that accepts values for both instance variables. Define minimal "set" methods (that do no editing) and simple "get" methods to return the value of their associated instance variable. Declare an abstract method named fullName that accepts no parameters and returns a String. This method must be implemented by subclasses to return the person's first and last name as a single String.
Code a class named Employee that subclasses Person. It should have a private field for storing the employee's pay rate (double). Provide a single constructor to initialize when last name, first name, and pay rate data values are received. Define a "set" method that will store the pay rate parameter if it is greater than or equal to zero. Otherwise, it should store a zero value. Provide a "get" method to return the value of the pay rate as a double. Define the abstract fullName method to return the employee's name in last name, first name format (such as "Doe, Jane"). Finally, code an overriding toString() method that uses the fullName() method to build and return a String containing all employee information in some meaningful format.
Code an interface named Billable that contains a single abstract method named amountDue. The method accepts no parameters and returns a double.
Code a class named Customer that subclasses Person and implements the Billable interface. It should have a private field for storing the customer's balance (double). Provide a single constructor to initialize when first name, last name, and balance data values are received. Define a minimal "set" method that will store the balance parameter without editing. Provide a "get" method to return the value of the balance as a double. Define the abstract fullName method to return the customer's name in standard format (such as "Jane Doe"). Code an overriding toString() method that uses the fullName() method to build and return a String containing all customer information in some meaningful format. Finally, be sure to implement the amountDue() method required by the Billable interface. If the customer has a balance greater than zero, the amount due must be the customer's balance plus 1.5 percent. For example, if the customer's balance is $100 their amount due is $101.50. If the customer has a negative balance, the amount due must be zero.
Define a public class named App having a main() method that defines the processing of customers and employees as follows:
Declare a Vector of Person object references. To support this, be sure to code an import statement for the java.util package at the beginning of your source file.
Provide a menu-driven main processing loop with a menu similar to the following (the exact layout is up to you):
PERSON PROCESSING MENU |
1 Add a customer |
2 Add an employee |
3 Show all billable persons |
4 Show all customers |
5 Show all employees |
6 Show all persons |
7 Exit |
The processing of menu choices 1 and 2 should simply prompt the user for all customer or employee data, construct the object, and add it to the Vector.
The processing of menu choice 3 should display one line of information about each billable person that owes money. Other persons are to be ignored. The output format is up to you, but use my Utility.moneyFormat() method to display the amount owed in proper currency notation.
The processing of menu choice 4 should display one line of information about each customer using its toString() method.
The processing of menu choice 5 should display one line of information about each employee using its toString() method.
The processing of menu choice 6 should display one line of information about each person using its toString() method.
Nothing needs to be done for menu choice 7.
If the user makes an invalid menu choice, display an appropriate error message and re-display the menu.
Miscellaneous
As always, use my Keyboard class to read input data from the keyboard and the methods of my Utility class to help format output.
You are free to choose the way in which the menu is displayed, the looping technique, prompt messages, and error messages. Be creative, but make sure the program is easy for an untrained user to run.
To see a similar program and get some ideas, review my Sample 04 program.
Grading criteria
Your program will be worth 30 points to be awarded as follows:
Accuracy (20 points). The program should correctly perform all specified processing.
Creativity (5 points). The program should be original yet simple in design.
Maintainability (5 points). The program should contain useful comments, meaningful identifiers, and be logically structured. It should include an opening documentation block with your name and a brief description of what the program does. It should also have a block of comments in front of every major section of code (loops, decisions, cases, etc.).
Submission
E-mail me the contents of your App.java source file no later than midnight on the program due date. If you are using JBuilder 4 and the Test project previously copied from the College of Business network, this file will be in the src folder of the project. In the College of Business labs, the complete path of your source file is:
D:\Test\src\App.java
To verify that you are doing this properly, e-mail to yourself, copy the source code to your test project, and re-test the program. If it works for you, it will probably work for me.
Upon receipt of your project, I will send you a verification message. When your project has been graded, you will receive an e-mail with your project score and comments (based on the above criteria). All project scores will be posted on the Internet within a few days after the due date.