Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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 ArrayList0; [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

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

Q.1. Taxonomic classification of peafowl, Tiger and cow ?

Answered: 1 week ago

Question

Q .1. Different ways of testing the present adulterants ?

Answered: 1 week ago

Question

Q.1. Health issues caused by adulteration data ?

Answered: 1 week ago