Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise 1 - Design and Implementation of a Shopping Cart using Classes, Objects and ArrayList. When you are shopping, you put Items in a Shopping
Exercise 1 - 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. ArrayList can be of any type including type: Integer, Double and String as well as Objects of other classes. Such as Item class defined above.) Eq. ArrayList- cartItems = new ArrayList
- 0; [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. 12 Marks Questions to consider: Do these need a default constructor? How to make sure the toString is nicely formatted? (3 Marks Write a Shopping Tester Class to test the shopping cart and print the output on the console. A sample output is shown below. [4 Marks 2. Problems @ Javadoc Declaration Console 3 Debug
Shopping Cart Tester (Java Application) C:\Program FilesVava\jre7 bin javaw.exe Shopping Cart Quantity Item Lindt Chocolate Eye Glass Wipes Green Apples Unit Price $4.99 $2.50 $0.21 Total $14.97 $10.00 $2.52 12 Total Price: $27.49
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 Started