Derive a class bulkdiscount from discount policy as


Question: Derive a class Combined Discount from DiscountPolicy, as described in Exercise I. It should have a constructor that has two parameters of type DiscountPolicy. It should define the method compute Discount to return the maximum value returned by compute Discount for each of its two private discount policies. The two discount policies are described in Exercises II and III.

Exercise I: Create an abstract class DiscountPolicy. It should have a single abstract method computeDiscount that will return the discount for the purchase of a given number of a single item. The method has two parameters, count and itemCost.

Exercises II: Derive a class BulkDiscount from Discount Policy, as described in the previous exercise. It should have a constructor that has two parameters, minimum and percent. It should define the method computeDiscount so that if the quantity purchased of an item is more than minimum, the dis-count is percent percent.

Exercises III: Derive a class BuyN/temsCetOneFree from DiscountPolicy, as described in Exerdse I. The class should have a constmctor that has a single parameter n. In addition, the dass should define the method computeDi scount so that every nth item is free. For example, the following table gives the discount for the purchase of various counts Man item that costs 510, when n is 3.

Count          1       2        3        4        5        6        7

Discount      0       0        10      10       10      20      20

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Derive a class bulkdiscount from discount policy as
Reference No:- TGS02457254

Now Priced at $15 (50% Discount)

Recommended (92%)

Rated (4.4/5)