java assignment

profilesehj
a1_ex1.html

COMP 1020

 

Exercise 1

One of the original goals of our program was performing an inventory check, to find out what items need to be reordered. Right now, there is no way to do so. To complete the program, we will add an additional method that can find if the stock of an item is too low. We can define "too low" as being "less than 25% of the original quantity when the item's object was created".

Download the complete Hardware Store program and add the following features to it:

  1. First, add an additional instance variable reorderQuantity (type int). In the constructor, initialize it to the quantity divided by 4 (using integer division; do not change the constructor's parameters).
  2. Next, modify the toString() method to include this value in its results.
  3. Then, add a new instance method to the Item class: mustReorder() which returns a boolean value, true if the quantity of the item is less than the reorderQuantity, or false if there is at least that amount of the item still available.
  4. Finally, test your new code by writing a static method checkInventory in the main class. Pass it the entire array containing the inventory, and call mustReorder() for every item. If the method returns true, call order() (the static method) to order 200 more of that item.

Test your new code by calling checkInventory after the initial round of sales, and printing the inventory afterwards. Add a few more sales to the program (cause some items to reach low inventory), and call it again.

Submit your updated Item class and the checkInventory method (only) by the due date specified in the course schedule.