Computer Science 261
Assignment # 4
Due: Monday, Sept. 24
Purpose:
- To gain experience in specifying a class in Java.
Write a PartObject class description for parts with the
following fields and methods:
- Fields
- Part Number (String)
- Part Name (String)
- Amount On Hand (integer)
- Unit Cost (double)
- Inventory Cost (which will be computed as the product of
amount on hand and unit cost - double)
- Methods
- Constructors
- Default constructor (set everything to blank strings and
zeros)
- Constructor accepting all fields except the inventory
cost, which the program should compute
- Other Methods
- GetPartInfo (similar to GetStudentInfo)
- print
- GetPartNumber (returns a String)
- GetPartName (returns a String)
- GetAmountOnHand (returns an integer)
- GetUnitCost (returns a double)
- GetInventoryCost (returns a double)
- SetAmountOnHand(int amount) resets the amount on
hand to amount, recomputes InventoryCost
- SetUnitCost(double cost) resets the unit cost to
cost, recomputes InventoryCost
Please note: Although this is intended to be picked up after
midnight Monday, it is also provided as review for the first hour
exam. Please try to have as much of this done by Thursday as you can,
so that problems you are having can be discussed in class Thursday as
part of the review that day for the exam.
I will provide shortly a main program to test your program out
(look at the main program for StudentObj for an example of what the
main program might look like)
Questions? Please ask!