CSci 161 A

Third exercise set

Due:   In class Friday, October 10

Implement the Part class as described on Exam #1 (using double instead of float), The Part class was described as having instance variables (fields) partName (a String), amtOnHand (a double), unitCost (a double), reorderLevel  (a double) and finally reorderAmount (again a double).  Note that the field reorderAmount has been added since the exam.

The public interface for this class will consist of

1.    Two constructors:

2.    Accessors as follows

3.    Modifiers as follows:

4.    Over-ride the toString method to produce a nicely formatted (so far as is possible at the moment) with all fields, each on a separate line (use \n to separate lines).

5.    You will want a private method checkReorder which will set the reorderAmount to the number of units that need to be reordered to set the amtOnHand to twice the reorderLevel if amtOnHand <= reorderLevel and to 0 otherwise.  Question:  Where do you want to invoke this method (possibly in several places)?

 

Test 1:  Add a new part with all fields entered but with a amtOnHand < reorderLevel and check to make sure that the reorderAmount is correctly set.  Check that getCost is correctly implemented.

Test 2:  Add a new part with all fields entered with amtOnHand > reorderLevel, but then use the setAmtOnHand to reduce the amtOnHand to an amount greater than zero but less than the reorderLevel  Check that the reorderAmount and getCost are correctly implemented.

Test 3:  Add a new part with only a part number and use the modifiers to set the other fields.  Then run getReorderAmount to see if that works correctly (actually, this should be two tests).

Record the results of these three tests in a document attached to the other deliverables.

Turn in:  Source listing for the class, the class documentation and a document describing the results of your tests..  To get to the class documentation, select Tools -> Project Documentation from the BlueJ project window (cntrl-J is a shortcut).  Be sure to test out all of your methods as follows: