Question: 1 . id ( int ) Acts as a unique identifier for the item class, this field should be constant 2 . count ( int

1. id (int) Acts as a unique identifier for the item class, this field should be constant
2. count (int) Tells us count of item
Member Functions
1. Constructor: Takes the id and the count and sets them, also makes all needed initializations
2. print Info: prints the id and count of the item
3. setter and getter for count.
4. getter for id
Class Shopping Cart
Data Members
1. uniqueItemCount
int, counter to keep track of number of unique items in shopping cart.
2. itemCount
int, counter to keep track of number of items in shopping cart.
3. itemsArray
Array to keep track of items in shopping cart.
Maximum itemCount of shopping cart is always 15
Type of array left for students
Member Functions
1. Constructor: Initialize any needed variables
2. printShoppingCart: prints the count of items, and the number of unique items, then prints the detail of each item.
3. addItem: adds an item to the items Array.
. We can't have two items in the array having the same id
If we add an item of id=5, and count =2, and then we add another item with the same id and with count 3, we should have one item with count 5.
. If you add an item that has count =5 to itemsArray, you shoul
increment items count by 5.
If we only have 3 space, and the user wants to add an item that has
count 5, we don't add anything to the array.
4. removeItem: takes as parameter an item id and removes that item from
itemsArray.
5. Destructor if needed.
3
Main / Testing
Each test should be in a separate function.
Test 1
1. Create 2 items (any valid id and count)
2. Print info for both items
Test 2
1. Create 20 items, item ids should be [0,1,2,3...etc] and count =1 for all 2. Add all items to shopping cart and Print Shopping Cart
Test 3
1. Create 1 item of count 15 and add item to itemsArray 2. Create another item of count 1 and add it to itemsArray 3. Print Shopping Cart
Test 4
1. Create 3 items, all items should have the same id. items have count 1,2,
3 respectively
2. Add 3 items to shopping and print shopping cart
Test 5
1. create one item of count =4 and id=4 and Print Shopping Cart 2. remove item with id =4 and Print Shopping Cart
Test 6
2. remove Item with id =3 and Print Shopping Cart 1. create two items with id =1 and another with id 23. remove item with id =1 and Print Shopping Cart

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 Programming Questions!