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
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 StartedRecommended Textbook for
Systems analysis and design
Authors: kenneth e. kendall, julie e. kendall
8th Edition
135094909, 013608916X, 9780135094907, 978-0136089162
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App