Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are going grocery shopping. I have start files for you. See UML diagrams below. I have completed the blueprint for the Inventory of items

You are going grocery shopping. I have start files for you. See UML diagrams below. I have completed the blueprint for the Inventory of items in our store. We know their name and the cost each. You need to create a blueprint for the CartItem for the items in your cart. This blueprint has an added field of how many of the items that you wish to purchase. You need to complete the driver ShopArray. I have added methods for loading and printing the inventory. You need to complete main() and the other methods below. We want to give the user the following choices in a loop until they choose 5 from the menu.
Choices:
1:add to cart 2:delete from cart 3:total cart value 4:display cart 5:end
import java.util.ArrayList;
public class ShopArray {
public static void main(String[] args){
//list of all items available
Inventory[] inventory = loadInventory();
//your cart
CartItem[] items = new CartItem[10];
printInventory(inventory);
System.out.println("Choices:
1:add to cart 2:delete from cart 3:total cart value "+
"4:display cart 5:end");
}
public static Inventory[] loadInventory(){
Inventory[] inv = new Inventory[7];
inv[0]= new Inventory("oranges",0.70);
inv[1]= new Inventory("bananas",0.35);
inv[2]= new Inventory("peppers",0.50);
inv[3]= new Inventory("burritos",4.50);
inv[4]= new Inventory("tacos",3.75);
inv[5]= new Inventory("whole chicken", 6.30);
inv[6]=new Inventory("Cheerios",5.50);
return inv;
}
public static void printInventory(Inventory[] inv){
System.out.println("Items:");
for (int i=0;i
image text in transcribed

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

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

More Books

Students also viewed these Databases questions