• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

tester class and then some.

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your professor seems to have an odd view of testing. Since tests, especially
unit tests, need to be run frequently, tests should only produce output if
they fail -- who wants to have to scan output to verify a test!

How should you test? Use JUnit!
[ April 26, 2006: Message edited by: Jeff Albertson ]
reply
    Bookmark Topic Watch Topic
  • New Topic