Question: the solution should written in c++ Question 4 Consider the following scenario. You are shopping in a supermarket and putting items into your shopping cart
the solution should written in c++
Question 4 Consider the following scenario. You are shopping in a supermarket and putting items into your shopping cart one-by-one. The supermarket has various ways of pricing items which are as follows: Simple Pricing The total cost is calculated simply by adding up the cost of each individual item purchased. Three-for-Two Promotions Buy three of any particular item, and pay for only two. This promotion is specific to the type of item being sold. For example, buy three bottles of All Gold Tomato Sauce, and pay for only two. Combo Deals A discount is applied when a specific combination of items is purchased. It would be handy if you could know the total cost of all of the items in your cart at any point in time. The following classes (Listings 4 and 5) model this scenario. Your tasks are as follows: a) Given the code in Listings 4 and 5 , write a number of unit tests to thoroughly verify that the ShoppingCart class is behaving as expected. (20 marks) b) Provide all the source code for your own solution to this problem. You are free to use the public interfaces provided and modify them to suit your needs. You may also discard them entirely. You can create any additional classes that you need. (15 marks) c) Comment on a noteworthy strength or weakness of the solution that you have given. (5 marks) class Item \{ public: Item(string name, double price); \}; Listing 4: Item's public interface class ShoppingCart \{ public: ShoppingCart(); void addItem(Item item); double total(); // returns the total cost of all items in the cart, with any discounts already applied \}; void createThreeForTwoPromotion(Item\& item); void createComboDeal (Item\& first_item_in_combo, Item\& second_item_in_combo, double discounted_total_price)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
