Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

More Books

Students also viewed these Databases questions