Question: Using c++ Objectives: 1. Students will use class inheritance to solve a problem 2. Students will write correct, will-documented and readable programs in a reasonable

Using c++ Objectives: 1. Students will use class inheritance to solve a problem 2. 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. Requirements Shopping cart o Design the shopping cart as a derived class from the Bag class o Declare total price as a data member o Define a default constructor o Define a member function to get the total price o Override the base class methods: add and remove Item 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: == Input : >> Output: << Write and document the class in header and implementation files, and compile it separately from the client program. You are required to use javadoc-style comments (page 759 of the textbook) in your code following the example of the ADT Bag interface template posted on D2L. Examples A run of the program might look like this: csci>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.99 2 Want to continue y/n-->y -->Sweater 39.99 1 Want to continue y/n-->y -->iphone_case 25.50 3 Want to continue y/n-->y -->Towel 9.99 5 Want to continue y/n-->n Here is your order: ------------------------------------------------- Name Unit_Price Quantity T-shirt $19.99 2 Sweater $39.99 2 iphone_case $25.5 3 Towel $9.99 5 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.99 1 The item is 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.99 2 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.99 2 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.99 5 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 Unit_Price Quantity T-shirt $19.99 2 Shoe $99.99 1 iphone_case $25.5 3 Towel $9.99 2 The total charge is $236.45 Thanks for shopping in XXX SHOPPING CENTER. ---------------------------------------------------

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!