Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please write the solution in c++ Question 4 Consider the following scenario. You are shopping in a supermarket and putting items into your shopping cart

image text in transcribedplease write the solution 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 the same item, and pay for only two. For example, buy three bottles of All Gold Tomato Sauce, and pay for only two. Multiple three-for-two promotions, on different items, may be active concurrently. 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 (Listing 3 and Listing 4) model this scenario. Your tasks are as follows: a) Given the code in Listing 3 and Listing 4, write a number of unit tests to thoroughly verify that the ShoppingCart class is behaving as expected. (15 marks) b) Provide all the source code for your own object-oriented 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. Your solution will be evaluated in terms of how well it conforms with good 0O design principles (information hiding, small classes, etc). You may assume that, in future, different types of promotions will come into effect, such as combo specials (reduced prices on certain combinations of items). (15 marks) Listing 3: Item's public interface class ShoppingCart f public: ShoppingCart(); void addItem(Item item); double total(); // total cost of items in cart, with discounts already applied \}; // Creates promotion, accepts item on promotion and cart to apply promotion to void createThreeForTwoPromotion(Item\& item, ShoppingCart\& cart)

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

More Books

Students also viewed these Databases questions

Question

Write a Python program to check an input number is prime or not.

Answered: 1 week ago

Question

Write a program to check an input year is leap or not.

Answered: 1 week ago