Create a class to encapsulate the data and behavior of an item in a store's inventory. The class should have the following data for an inventory item:

Product Number - String
Description - String
Quantity on hand - int
Product Price - double

The class should have a constructor that initializes all four instance variables. Be sure to follow the class style and use _ as the name for the parameter corresponding to the class instance variable. (Note the “_” starting the parameter name.)

You should code accessor and mutator (get and set) methods for all class instance variables. Be sure to follow the class style note.

If the product number or description is blank, or the values passed for the quantity or price are not valid, leave the associated instance variable unchanged.

Create a class method to calculate and return the total inventory amount for the product.

TestInventory.java

The main method in this class should prompt the user to enter data for a product, instantiate an inventory class object and use it to display all of the information about a product, including the total inventory amount for the product.

    • 12 years ago
    complete solution
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      inventory.java
    • attachment
      testinventory.java