Question
Write a JAVA PROGRAM Two parts to this assignment: 1. The Inventory Class - Defined by the class Inventory. - Models an item that can
Write a JAVA PROGRAM
Two parts to this assignment: 1. The Inventory Class - Defined by the class Inventory. - Models an item that can be found in a store's inventory. 2. The Inventory Program - This is a main class that tests and uses the Inventory class. - Defined by the class Main_Inve.
Both of these classes should be part of the same package.
NOTES:
The Inventory ID stored in the id member is a specially-formed String that consists of 3 letters (can be upper-case or lower-case), followed by a dash, followed by 4 numbers. For example, "abc-1234". All ID values must follow this pattern, otherwise they are invalid. The default ID value is "ABC-1234". The string name can't be a null object (e.g. null, not pointing to any object) and can't be a null-String (e.g. "" with trim() applied). The default string value is "New Item". "qoh" is short for Quantity On Hand, and represents the quantity of this inventory item currently in stock. For example, if there are 10 items currently in inventory, then the QOH is 10. QOH should always be 0 or more, never negative. The default value is 0. "rop" is short for Re-Order Point, and represents the amount that the QOH should remain above before this item needs to be re-ordered. Usually this is used in special reports (and you'll do these later in the course) to make a list of items that need to be ordered: if an item's QOH is more than the ROP, then there is enough of this item in stock; if the item's QOH is less than or equal to the ROP, then you must order more of this item before you run out of it. You won't need to worry right now about performing the QOH/ROP check, you only need to makesure that the ROP is more than 0, otherwise it's invalid. The default ROP is 25. The sellPrice represents the selling price per unit of this item. Selling Price must be 0 or more, and the default value is 0. The default constructor should initialize the data members to their default values, unless you already did this when you defined those data members. The multi-param constructors set the values of the appropriate data members to the param values. All mutator methods should only assign the param value if it is valid, otherwise an IllegalArgumentException is thrown with a specific, yet concise and informative error message. the toString() returns the Inventory object as a String in the following format: Item ID (Item Name), QOH: x Price: $x.xx where "Item ID" is the item's ID, "Item Name" is the actual name of the item, x is the value in the QOH member, and $x.xx is the value stored in the sellPrice member (formatted with a $ and 2 decimal places).
The error messages should be descriptive (what went wrong and how do you do it right?) but also concise, and should not be specific as to where param values came from. Better messages would be "Error: value must be greater than 0." or "Sorry, the value is not a valid number."
This program must be in the class called Main_Inve in your assignment 1 project. This program prompts the user to enter the inventory item ID, item name, quantity on hand, re-order point, and selling price of a specific inventory item of their choice. Use the methods of your Inventory class to ensure that the user's input is valid. If any input is not valid, repeatedly prompt the user to enter data until that data is valid. Note TIP: Construct a default Inventory object before you start getting the user's input. Then, for each user input, use a loop to make sure that particular input doesn't cause an exception when you use the appropriate mutator method: // construct default Inventory object REPEAT: PRINT "Enter [whatever data member you're asking for]:" GET userInput // TRY to assign userInput to the data member using // the mutator method // CATCH any exceptions: display an error msg to user WHILE the userInput is still invalid You can do that same block of code for each user input that requires validation. You could even use methods to eliminate redundant code (I used one for the strings, one for the integers, and one for the price/double).
After the user has entered all 5 input values: Display the Inventory object as a String. If the item needs to be re-ordered, display the message "You need to order more item name." where item name is the actual item name. Ask the user how much of the item they'd like to buy, then display the total cost (with HST of 13%) formatted to 2 decimal places. If the user enters 0 or less, just display $0 for the price. All user interaction and output should be displayed on the console/screen. Sample interaction and output below (you can use these values to test your program):
Example Output:
Enter Inventory Item ID: FEB-0302
Enter Item Name: Dog Litter, 25kg
Qty On Hand: 12
Re-Order Point: 14
Selling Price: 14.85
FEB-0302 (Dog Litter, 25kg), QOH: 12 Price: $14.85 You need to order more!
Method Members: + Inventory 0 + Inventory(id : String, name : String, sellPrice : double) + Inventory(id : String, name : String, qoh : int, rop : int, sellPrice : double) + getId 0: String +setId(id: String) : void + getName ( : String + setName(name : String) : void + getQoh ( : int ) +setQoh(qoh : int) : void + getRop 0 : int + setRop(rop : int) : void + getSellPrice() : double + setSellPrice(price : double) : void + toString ): StringStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started