Question: 1 . id ( int ) Acts as a unique identifier for the item class, this field should be constant 2 . count ( int
id int Acts as a unique identifier for the item class, this field should be constant
count int Tells us count of item
Member Functions
Constructor: Takes the id and the count and sets them, also makes all needed initializations
print Info: prints the id and count of the item
setter and getter for count.
getter for id
Class Shopping Cart
Data Members
uniqueItemCount
int, counter to keep track of number of unique items in shopping cart.
itemCount
int, counter to keep track of number of items in shopping cart.
itemsArray
Array to keep track of items in shopping cart.
Maximum itemCount of shopping cart is always
Type of array left for students
Member Functions
Constructor: Initialize any needed variables
printShoppingCart: prints the count of items, and the number of unique items, then prints the detail of each item.
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 and count and then we add another item with the same id and with count we should have one item with count
If you add an item that has count to itemsArray, you shoul
increment items count by
If we only have space, and the user wants to add an item that has
count we don't add anything to the array.
removeItem: takes as parameter an item id and removes that item from
itemsArray.
Destructor if needed.
Main Testing
Each test should be in a separate function.
Test
Create items any valid id and count
Print info for both items
Test
Create items, item ids should be etc and count for all Add all items to shopping cart and Print Shopping Cart
Test
Create item of count and add item to itemsArray Create another item of count and add it to itemsArray Print Shopping Cart
Test
Create items, all items should have the same id items have count
respectively
Add items to shopping and print shopping cart
Test
create one item of count and id and Print Shopping Cart remove item with id and Print Shopping Cart
Test
remove Item with id and Print Shopping Cart create two items with id and another with id remove item with id and Print Shopping Cart
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
