Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a smart shopping cart using JAVA. Think of the self-checkout option in many stores these days. Design a ShoppingCart class that contains Items. This

Create a smart shopping cart using JAVA. Think of the self-checkout option in many stores these days.

Design a ShoppingCart class that contains Items. This uses composition since there is an array of Item objects inside a ShoppingCart. Several interesting methods are

addItem to insert an item to the cart. This is a void method since it modifies the state of the array in the ShoppingCart object. There are different ways to implement this method. One was is to have a single parameter that is an already constructed Item. Another way is to have a set of parameters that are the parameters to the constructor of the Item class.

cartTotal computes the total price of the cart. This method returns a double but does not need any parameters since it works with data members of the ShoppingCart object.

cartTaxAmount receives the tax rate and computes the total tax to charge for the items currently in the cart. Only Taxable items should be considered for this calculation. This method also returns a double but does not need any parameters since it works with data members of the ShoppingCart object.

For simplicity, you can assume that the capacity of a ShoppingCart is fixed at 10 items.

Keep in mind:

Each class should have at least one constructor that receives arguments.

Make data members private and create accessor and mutator methods whenever necessary.

Each class should have a toString method that you use to display the contents of the class.

Please try to keep it basic. No imports or anything like that if possible.

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

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions

Question

Question May a taxpayer roll over money from an IRA to an HSA?

Answered: 1 week ago

Question

Question What is the doughnut hole in HSA coverage?

Answered: 1 week ago