Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Interacting with the Warehouse For the last Java component, we'll tie the last two together into a functioning program. On top of what has already
Interacting with the Warehouse For the last Java component, we'll tie the last two together into a functioning program. On top of what has already been completed, we'll add a simple terminal-based user interface. The WarehouseFrontEnd The task is to create a public class WarehouseFrontEnd, which will interact with the user allowing them to add items, remove items, print the current stock, sell and restock items and exit. It will need to create a stockDatabase (working code for both prior tasks is included, you don't need to recreate it) with which to interact. WarehousefrontEnd should contain the main method for the program, and this will be the entry point for the tests. When the program starts, it should print Welcome to the warehouse!, and then display the menu: What would you like to do? 1. Print current stock. 2. Add an item to the inventory. 3. Remove an item from the inventory. 4. Add stock to an item. 5. Sell an item. 6. Exit the system. It should then prompt the user to enter their choice with Enter the number of your choice: and read input from the user. If the input is not a valid choice (a number from 1 to 6), the program should print: That is not a valid choice. Enter the number of your choice: And keep doing so until a valid choice is entered. If option 1 is chosen, the program should print the current database, then return to the menu and prompt the user for further action. If option 2 is chosen it should read in an id, a name and an initial quantity for an item with the following prompts: Enter new item id: Enter new item name: Enter initial quantity: It should then create that item and add it to the warehouse if there is no item with that id, then return to the menu and prompt for further action. If there is already an item with that id, it should print An item with that ID already exists. and then return to the menu and prompt for further action. If option 3 is chosen, it should prompt the user for an id with: It should read in the id and if there is an item with that id, it should remove it from the warehouse, if there is not, it should print: There is no item with that ID in the warehouse. It should then return to the menu an continue as normal. If option 4 is chosen, it should prompt the user to enter an id and a quantity to add to the stock of the item with that id, reading input at each prompt Enter item id: Enter additional quantity to add: If both are valid, it should add that quantity to that item, if the id is invalid, it should print the same text as for option 3, if the id is valid but the quantity isn't, it should print: You cannot stock that quantity. It should then return to the menu as with all other options so far. If option 5 is chosen, it should do essentially the same as option 4, except it it should prompt the user with: Enter quantity to sell: instead of asking for a restock quantity and if everything is valid it should sell that amount of the item, rather than restock it, and if the quantity is invalid, is should print: You cannot sell that quantity. The message for an incorrect id is the same as before. It should then return to the menu and continue. If option 6 is chosen, it should print: Bye! and exit the program. Additional Comments
Step 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