Answered step by step
Verified Expert Solution
Link Copied!

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, will-documented 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 1- 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 2- 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++ project2.cpp
a.out
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!)
--> T-shirt 19.992
Want to continue yn-y
-->Sweater 39.992
Want to continue yn-y
-->iphone case 25.503
Want to continue yn-y
-->Towel 9.995
Want to continue yn-n
Here is your order:
Name
T-shirt
Sweater
iphone case
Towel
The total charge is $246.41
Want to modify your order? y/n-->y
What do you want? Enter 1: add 2: remove 3: change quantity
-1
Enter the item to add as the following order:
name unitprice quantity--> shoe 99.991
The item has been added.
Want to modify your order? y/n-->y
What do you want? Enter 1: add 2: remove 3: change quantity
-->2
Enter the item to remove as the following order:
name unitprice quantity
--> Sweater 29.992
No such item in your shopping cart!
Want to modify your order? y/n-->y
What do you want? Enter 1: add 2: remove 3: change quantity
-->2
Enter the item to remove as the following order:
name unitprice quantity
--> Sweater 39.992
The item has been removed.
Want to modify your order? y/n-->y
What do you want? Enter 1: add 2: remove 3: change quantity
-->3
Enter the item to change as the following order:
name unitprice quantity
--> Towel 9.995
Enter a new quantity -->-2
-2 is not a valid input.
Enter a new quantity -->2
The quantity has been modified.
Want to modify your order? y/n-->n
Here is your updated order:
You have ordered the following items:
Name
T-shirt
Shoe
iphone case
Towel
The total charge is $236.45
Thanks for shopping in XXX SHOPPING CENTER.
Other requirements
For each program, add the following information at the top of the file:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analytics Systems Engineering Cybersecurity Project Management

Authors: Christopher Greco

1st Edition

168392648X, 978-1683926481

More Books

Students also viewed these Databases questions

Question

On which points do sources agree?

Answered: 1 week ago