Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Note: shopping cart and Item must be a regular class and also include main.cpp where you can add remove items Objectives: 1. Students will use

Note: shopping cart and Item must be a regular class and also include main.cpp where you can add remove items 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. 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 should not be required to be same! Input : >> Output: << !!Test the class Item before you move to next task!! Task 2 - Shopping cart (a regular class) o Design the shopping cart as a derived class from the Bag class using public inheritance as follows: class ShoppingCart::public Bag 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. [hint] Similar to setItem() function in toyBox class !!Test the class before you move to next task!! Requirements Write and document the class in header and implementation files, and compile it separately from the client program. Add the implementation of ShoppingCart class at the end of the header file ShoppingCart.h as follows: CSCI 301 Computer Science II Spring 2023 #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.

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

Step: 3

blur-text-image

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

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions