Question
You will model ShoppingCart as java Class. ShoppingCart class will store Items in the cart. Item will be another java class. Item is identified by
You will model ShoppingCart as java Class.
ShoppingCart class will store Items in the cart. Item will be another java class.
Item is identified by Id attribute. If the Item with the same Id is added multiple times in the cart, change the quantity and DO NOT add multiple Item objects with same Id.
The program should prompt various actions on ShoppingCart addItemToCart Two overloads
updateItemQuantity
removeItemFromCart
calculateItemBasedDiscount
getTotalCost
Based on the selected action ask for further input. For example, if user selects to addItemToCart, prompt user to enter:
itemId
itemName
itemPrice
itemQuantity
Implement all methods in ShoppingCart.java
Write test in ShoppingCartTester.java.
Use scanner to implement userInputSimulator() method.
See sample output for sample run. Before you start working on user input, implement the tester methods as provided in the starter code. Once you have everything working enable the user input and comment out the tester code. Gracefully exit the program
Sample Output WELCOME TO SHOPPING CART APPLICATION. PLEASE ENTER YOUR NAME:
Joe Peters Welcome Joe Peters. Your Shopping Cart is created.
-----------------------------------------------------------------------------
Select one of the following options:
Add Item in ShoppingCart
Update Quantity for Item in ShoppingCart
Remove Item from Shopping Cart
Calculate Item Based Discount
Get total cost
Exit
1
You have selected to Add Item in Shopping Cart
Please Enter Item Id: 123
Please Enter Item Price: 20.50
Please Enter Item Quantity: 20
Item "Id: 123, Cost: $20.50" is added in ShoppingCart with Quantity 20
Select one of the following options:
Add Item in ShoppingCart
Update Quantity for Item in ShoppingCart
Remove Item from Shopping Cart
Calculate Item Based Discount
Get total cost
Exit
2
You have selected to update Quantity for Item in ShoppingCart
Please Enter Item Id for which you want to change Quantity: 123
Please Enter new Quantity: 25 Quantity for Item "Id: 123, Cost: $20.50" is changed to 25
Select one of the following options:
Add Item in ShoppingCart
Update Quantity for Item in ShoppingCart
Remove Item from Shopping Cart
Calculate Item Based Discount
Get total cost
Exit 6
Are you sure you want to Exit(y/n)?
y
Good Bye Have a Nice Day!
//end sample output
Make sure you create helper methods instead of putting entire testing code in Main method for getting options and calling appropriate function once you receive the options.
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