Question
This is C++ Programming.. Implement the class structure that represents a shopping cart for an online shop and items that can be put in the
This is C++ Programming..
Implement the class structure that represents a shopping cart for an online shop and items that can be put in the shopping cart. Create the following classes. Use appropriate access modifiers (member variables should be private!) and data types for each. Dont forget to add getter and setter functions for each member variable.
Item: This class has the member variables called title, description, and price. It has a pure virtual function called print (void print () = 0;). This function is NOT implemented in this class but must be implemented/overridden in the three subclasses below and print the type and title of the current object to the console.
Book: This class inherits from Item. It has an instance variable called page Count.
Movie: This class inherits from Item. It has an instance variable called length.
CD :This class inherits from Item. It has an instance variable called track Count.
Shopping Cart :This class keeps track of items that were bought.
It has a single constructor which expects the maximum number of items that can be placed in the cart. It must have a dynamically allocated array of pointers to an item object (Item** array;)which is initialized in the constructor (array =new Item*[size]).The cart must have functions to add an item object to the cart and print the items currently in the cart to the console by calling each objects print()function. Finally, implement a main function that creates a shopping cart object. Then add one item of
Each type to the shopping cart and finally list the items in the cart on the console. Library:
You need to include
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