Question: Demonstrate the following: Usage of Eclipse Variable Assignment Looping (for, while etc) ArrayList (using object) Object based programming User Interaction with multiple options Implementing Methods

Demonstrate the following:

Usage of Eclipse Variable Assignment Looping (for, while etc) ArrayList (using object) Object based programming User Interaction with multiple options Implementing Methods in relevant classes Instructions

Start with this java classes Item.java, ShoppingCart.java, and ShoppingCartTester.java

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

Implement discount based on total quantity of items

- If total number of quantity ACROSS ALL Items is less than 11 , apply LOW_DISCOUNT (10% discount)

- If total number of quantity ACROSS ALL Items is more than 10 but less than 26, apply MEDIUM_DISCOUNT (25% discount)

- If total number of quantity ACROSS ALL Items is more than 26, apply HIGH_DISCOUNT (50% discount)return discount; }

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:

1. Add Item in ShoppingCart 2. Update Quantity for Item in ShoppingCart 3. Remove Item from Shopping Cart 4. 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!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!