Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Classes (rule-ofS, type members) Create a family of class named Collection {a template class] that manages a dynamically allocated collection of items of any type.

image text in transcribedimage text in transcribed
Classes (rule-ofS, type members) Create a family of class named Collection {a template class] that manages a dynamically allocated collection of items of any type. The class should support the following operations: ' create an empty collection ruleofS add an item re move an item retrieve the item at a specied index modify the item from a specied index print the content of the collection to screen re move all items remove all items that match a certain condition (a lambda expression received from the client as a parameter} ' create a new collection that contains only items that match a certain condition {a lambda expression received from the client as a parameter} The class should use exceptions to inform the client when an operation cannot be completed Keg\" bad parameters] too are provided with the following code enum class ItemType { Clothing, Electronics, Appliance, Book, Movie, Computers, Tools, Gaming, Sports } class Item { const ItemType m_category; std::string m_description{}; std::string m_id{}; double m_price{}; double m_discount{};ff a number in the interval [3, 1] I! } class ShoppingCart ! I u: I HvLJIIUIIJI'L|_I'IIJI.II'II1\\_I double m_discount{}3ff a number in the interval [8, 1] if ... } class ShoppingCart { Item' m_pItems{}; if a dynamically allocated array of items in the shopping cart size_t m_cnt{}; if ... } ' Add to the two classes members to support the following operations: * ShoppingCart - add items to the shopping cart - remove items from the shopping cart - nJIe-o'f-E for the shopping cart - remove from the shopping cart all items from a specified category {e.g., ItemType::Too|s]I - remove from the shopping cart all items that don't have a discount (discount is CI) - update the discount on all items in a shopping cart that belong to a certain category (e.g., |temType::Book} - remove from the shopping cart all items that match a predicate received as a parameter (this is a lambda expression} - print to screen the content of the shopping cart, formatted as a table . Item - in a class variable in class Item, count how many objecE in the category ItemType::Gaming exist in the program [created but not yet destroyed) - in a class variable in class Item; count how many discounted objects exist in the program {created but not yet destroyed). Note that the m_discount attribute can change duringthe lifetime of an object; this counter must be updated when an item becomes discounted or is not discounted anymore. - add class functions to access the value of these counters ' Derived class - create a new class derived from ShoppingCart that doesn't allow multiple items with the same ID (override the relevant fu nctions}. - add to this class an attribute of type char* that is a userprovidedname for the shopping cart (e.g., Gifts for John, Party for Alice] Home improvement, Trip to Europe] this is a resource and should be managed by the class: implement ruleofS. * All attributes must be private (make functions to access them}; do not use global variables

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

11. What is a central bank swap?

Answered: 1 week ago

Question

Explain methods of metal extraction with examples.

Answered: 1 week ago