I've got this large program I'm supposed to put together, but I'm running into a few problems. Here is the code:
I am having trouble completing the "test" section of my code, as well as completing the hierarchy all together. The way I have the program coded as of right now compiles, but produces no results, which is why I need help with the "test" code. There are a few other things I might be able to figure out on my own after writing the
test code, but if not I will just post again.
These are some guidelines I was provided with:
Completing the class hierarchy...
A guide in defining the classes needed to complete the class hierarchy.
1. A Customer is a Person who has a balance (double). Provide a single constructor that will receive the customer's name, address, and balance. The name and address must be passed through to the superclass constructor while the balance can be passed to the "set" method that will store it. Be sure to code the necessary "set" and "get" methods for balance but do NOT be concerned with editing the data. Provide a toString method that overrides the one inherited from the superclass. This method must return a concatenated
string consisting of the string returned by the toString method of the superclass and the customer's balance in currency format (using the moneyFormat method of the Utility class).
2. An Employee is a Person who is Payable and has a salary (double). Provide a single constructor that will receive the employee's name, address, and salary. The name and address must be passed through to the superclass constructor while the salary can be passed to the "set" method that will store it. Be sure to code the necessary "set" and "get" methods for salary but do NOT be concerned with editing the data. Provide a toString method that overrides the one inherited from the superclass. This method must return a concatenated string consisting of the string returned by the toString method of the superclass and the employee's salary in currency format (using the moneyFormat method of the Utility class). Also provide a pay method that will return the value of the employee's salary divided by 24 as a double.
3. A SalesRep is an Employee who has sales and a commission rate (both double). Provide a single constructor that will receive the sales rep's name, address, salary, sales, and commission rate. The name, address, and salary must be passed through to the superclass constructor while the sales and commission rate can be passed to the "set" methods that will store them. Be sure to code the necessary "set" and "get" methods for sales and commission rate but do NOT be concerned with editing the data. Provide a toString method that overrides the one inherited from the superclass. This method must return a concatenated string consisting of the string returned by the toString method of the superclass, the sales rep's sales (in currency format using the moneyFormat method of the Utility class), and the sales rep's commission rate (in percent format using the percentFormat method of the Utility class). Also provide a pay method that overrides the one inherited from the superclass. The method must return the sum of the value returned by the superclass pay method and the sales rep's commission (their sales times their commission rate).
Completing the Project03 class...
Complete the test code as follows:
1. Declare an array of Person object references capable of holding 10 elements.
2. Create an Employee object with the employee's name, address, and salary and add the object's reference to the array.
3. Create a Customer object with the customer's name, address, and balance and add the object's reference to the array.
4. Create a SalesRep object with the sales rep's name, address, salary, sales, and commission rate and add the object's reference to the array.
5. Code a for loop to process the array. For each non-null element, use the object's toString method to display information about the Customer, Employee, or SalesRep. Then, if the object is Payable, use the object's pay method to display their pay in currency format (using the moneyFormat method of the Utility class).
Output should look SOMETHING like this:
Employee: Barb Webb, 123 Maple, Salary: $24,000.00
Pay is: $1,000.00
Customer: Todd Kent, 4321 Oak, Balance: $150.00
SalesRep: Ted Na, 654 Elm, Salary: $18,000.00, Sales: $9,000.00, Comm Rate: 6%
Pay is: $1,290.00
Any help or suggestions would be appreciated, and thanks a lot for even taking the time to look at this. I know it's a lot.