Question: java, please work of given code and not rewrite Task is to create a method public void viewCart() for the Cart class that prints out
java, please work of given code and not rewrite
Task is to create a method public void viewCart() for the Cart class that prints out the products in the cart in clear way using
public class Cart {
BagInterface Cart;
public Cart() {
cart = new Bag<>(); }
public Cart(Product[] products) {
cart = new Bag<>();
// constructor
for(int i = 0; i
cart.add(products[i]); //addds to cart
}
}
}
for example
Product[] products = {
new Product("taco"3.25),
new Product("taco"3.25),
new Product("taco", 3.25),
new Product("burrito", 9.50)
};
Prints
3x taco 3.25 each
1x burrito 9.50 each
total cost: $19.25
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
