Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Objectives: Students will use class inheritance to solve a problem Students will write correct, will - documented and readable programs in a reasonable amount of
Objectives:
Students will use class inheritance to solve a problem
Students will write correct, willdocumented and readable programs in a reasonable
amount of time.
Problem Description:
When shopping online, you select items and add them to a shopping cart. Duplicate items
are permitted in a shopping cart, as you can purchase multiples of the same item. You
also can remove an item from a shopping cart, if you change your mind about buying it
The shopping cart can show its current contents with their prices and the total cost of
these items. Design the ADT item and shopping cart.
Task Item a regular class, not a template
Declare three data members: name of item, unit price of item, and quantity of
item
Define a default constructor
Define a constructor that initializes all three data members by the parameters.
Define set and get functions for each data member.
Define the following operators:
Equal to:
two items are same if their name and price are same; quantity is
required to be same!
Input :
Output:
Test the class Item before you move to next task!!
Task Shopping cart a regular class, not a template
@ Design the shopping cart as a derived class from the Bag class using
public inheritance as follows:
class ShoppingCart:public Bag#include "ShoppingCart.cpp
before the line #endif
This is required to run your program correctly on centOS.
Testing
Design your test data to test ALL operations provided in the ShoppingCart:
Add
Remove two cases: in the cart and not in the cart
Change quantity two cases: in the cart and not in the cart If in the cart, validate
the quantity.
The running result of the program must look like this:
g projectcpp
aout
Welcome to XXX SHOPPING CENTER.
Enter the item you selected as the following order:
name unitprice quantity
Name can not contain any space. Otherwise errors happen!
Tshirt
Want to continue
Sweater
Want to continue
iphone case
Want to continue
Towel
Want to continue
Here is your order:
Name
Tshirt
Sweater
iphone case
Towel
The total charge is $
Want to modify your order? yny
What do you want? Enter : add : remove : change quantity
Enter the item to add as the following order:
name unitprice quantity shoe
The item has been added.
Want to modify your order? yny
What do you want? Enter : add : remove : change quantity
Enter the item to remove as the following order:
name unitprice quantity
Sweater
No such item in your shopping cart!
Want to modify your order? yny
What do you want? Enter : add : remove : change quantity
Enter the item to remove as the following order:
name unitprice quantity
Sweater
The item has been removed.
Want to modify your order? yny
What do you want? Enter : add : remove : change quantity
Enter the item to change as the following order:
name unitprice quantity
Towel
Enter a new quantity
is not a valid input.
Enter a new quantity
The quantity has been modified.
Want to modify your order? ynn
Here is your updated order:
You have ordered the following items:
Name
Tshirt
Shoe
iphone case
Towel
The total charge is $
Thanks for shopping in XXX SHOPPING CENTER.
Other requirements
For each program, add the following information at the top of the file:
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