Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, i need help in java language In this assignment, you will write efficient Java code to create a basic inventory system for a produce

Hello, i need help in java language

In this assignment, you will write efficient Java code to create a basic inventory system for a produce stand using a dynamically allocated data structure to hold the inventory. Your code must handle every single possible condition and never crash. The inventory system will contain three types of items fruit that is purchased from an orchard for resale; vegetables that are purchased from a farm for resale; and preserves that are made by the produce stand themselves for sale. Our program will run with a basic menu that allows the user to add an item to inventory, display to the screen the inventory, buy an item (i.e. add to the quantity of that item) and sell an item (i.e. subtract from the quantity of that item). You are allowed to buy and sell any item (fruit, vegetable or preserve) in the inventory.

  1. You must also submit a test plan for the functionality created in this assignment. You can use this Test Plan Template.
  2. Create classes according to the class diagram below. You must adhere to the exact naming, parameters and return values in the class diagram as we will rely on this when marking. You may disregard the yellow folder icon in the vegetable class in the diagram. It will help to read the written requirements outlined below so you don't get muddied in the class diagram.
  3. All data members must never be public. You should make them all private unless they are in a base class AND they are needed in the child classes
  4. For this assignment, we will limit the inventory array to a maximum of 20 entries
  5. Create a console application that will display the following menu repeatedly until the user selects the exit item. Ensure that your program will never crash nor exit in any other circumstances. The menu should be displayed again if an incorrect value is entered (i.e. a number that is not between 1-5 or any other character) after displaying the error message "Incorrect value entered". The menu should look exactly like this:
  6. Please select one of the following:
    1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: To Exit > 
  7. sample output :
  8. Please select one of the following: 1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: To Exit > 2 Inventory: Please select one of the following: 1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: To Exit > 3 Error...could not buy item Please select one of the following: 1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: To Exit > 4 Error...could not sell item Please select one of the following: 1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: To Exit > 1 Do you wish to add a fruit(f), vegetable(v) or a preserve(p)? w Invalid entry Do you wish to add a fruit(f), vegetable(v) or a preserve(p)? 1 Invalid entry Do you wish to add a fruit(f), vegetable(v) or a preserve(p)? f Enter the code for the item: 111 Enter the name for the item: Granny Smith Apple Enter the quantity for the item: 30 Enter the cost of the item: .10 Enter the sales price of the item: .25 Enter the name of the orchard supplier: Apple Orchard Please select one of the following: 1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: To Exit > 2 Inventory: Item: 111 Granny Smith Apple 30 price: $0.25 cost: $0.10 orchard supplier: Apple Orchard Please select one of the following: 1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: To Exit > 1 Do you wish to add a fruit(f), vegetable(v) or a preserve(p)? v Enter the code for the item: 222 Enter the name for the item: Orange Carrot Enter the quantity for the item: 100 Enter the cost of the item: .25 Enter the sales price of the item: 1.00 Enter the name of the farm supplier: McDonald's Farm Please select one of the following: 1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: To Exit > 1 Do you wish to add a fruit(f), vegetable(v) or a preserve(p)? p Enter the code for the item: 333 Enter the name for the item: Raspberry Jam Enter the quantity for the item: 10 Enter the cost of the item: 4.50 Enter the sales price of the item: 5.50 Enter the size of the jar in millilitres: 500 Please select one of the following: 1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: To Exit > 1 Do you wish to add a fruit(f), vegetable(v) or a preserve(p)? f Enter the code for the item: ee Invalid code Enter the code for the item: -123 Enter the name for the item: Test Enter the quantity for the item: ee Invalid entry Enter the quantity for the item: -19 Invalid entry Enter the quantity for the item: 20 Enter the cost of the item: -3 Invalid entry Enter the cost of the item: h Invalid entry Enter the cost of the item: 3.4 Enter the sales price of the item: -9 Invalid entry Enter the sales price of the item: e Invalid entry Enter the sales price of the item: ! Invalid entry Enter the sales price of the item: 3.50 Enter the name of the orchard supplier: Test Orchard Please select one of the following: 1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: To Exit > 2 Inventory: Item: 111 Granny Smith Apple 30 price: $0.25 cost: $0.10 orchard supplier: Apple Orchard Item: 222 Orange Carrot 100 price: $1.00 cost: $0.25 farm supplier: McDonald's Farm Item: 333 Raspberry Jam 10 price: $5.50 cost: $4.50 size: 500mL Item: -123 Test 20 price: $3.50 cost: $3.40 orchard supplier: Test Orchard Please select one of the following: 1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: To Exit > 3
  9. image text in transcribed
Foodtom Code Sitemare: String rication Quartok: Costa Foodiem): Fouditem String updateitem (mountint): boolean is Equal (item: Fooditem): boolean additam scanner Scanner): boolean lopusCade scanner : Scanner ) boolean Fruit Preserve Vegetable Sarmamein Vegetable: Vegetable toString(): String diam scanner : Scanner bolan orchard: String Fruit Fruit Preserve): Preserve toString() String additom (scanner: Scanner too ditem(scanner : Scanner:boolean Inventory inventory Foodiem 0.1 Inventory (): Inventory alreadyExists(Item: Fooditem); int adiditemscanner : Scanner): boolean updateQuantity scanner : Scanner, buyOrSell: boolean ) boolean Assign 1 main (args : String (1..')) displayMenu()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions