In c++
Posted: Sun Jul 03, 2022 10:00 am
In 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. 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: <<
Task 2 - Shopping cart (a template) 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. !!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 Shopping Cart class at the end of the header file "ShoppingCart.h" as follows: #include "Shopping Cart.cpp" (before the line #endif) **This is required to run your program correctly on centOS.
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: <<
Task 2 - Shopping cart (a template) 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. !!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 Shopping Cart class at the end of the header file "ShoppingCart.h" as follows: #include "Shopping Cart.cpp" (before the line #endif) **This is required to run your program correctly on centOS.