Question: Complete the following problem using Java Design and Implementation of a Shopping Cart using Classes, Objects and ArrayList. When you are shopping, you put Items
Complete the following problem using Java Design and Implementation of a Shopping Cart using Classes, Objects and ArrayList.
When you are shopping, you put Items in a Shopping Cart. [Define Item as a Class]. [2 Marks]
An Item has a name, a price, and a quantity [These are variables/instance data of the Item Class]
Constructor, Getters/Setters [3 Marks]
A Shopping Cart Class is now defined which has a size, a total price, and a collection of Items (Define ArrayList of type Items)
[2 Marks]
Provide a method to add an item to the cart and to check if the cart is empty. [4 Marks]
Provide a method to find totalprice of all shopped items in cart. [2 Marks]
Questions to consider:
Do these need a default constructor?
How to make sure the toString is nicely formatted? [3 Marks]
Write a Tester Class to test the shopping cart and print the output on the console. [4 Marks]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
