Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solution in C++ please Question 4 Consider the following scenario. You are shopping in a supermarket and putting items into your shopping cart one-by-one. The

image text in transcribed

Solution in C++ please

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 pur- chased. 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) 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); Listing 5: Shopping Cart's public interface and discount setup methods

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

(1 point) Calculate 3 sin x cos x dx.

Answered: 1 week ago

Question

What is DDL?

Answered: 1 week ago