Derive a class BuyNItemsGetOneFree from DiscountPolicy, as describedin Exercise 10. The class should have a constructor that has a singleparameter n. In addition, the class should define the methodcomputeDiscount so that every nth item is free. For example, the followingtable gives the discount for the purchase of various counts of an item thatcosts $10, when n is 3:Count 1 2 3 4 5 6 7Discount 0 0 10 10 10 20 2013. Derive a class CombinedDiscount from DiscountPolicy, as described inExercise 10. It should have a constructor that has two parameters of typeDiscountPolicy. It should define the method computeDiscount to returnthe maximum value returned by computeDiscount for each of its twoprivate discount policies. The two discount policies are described inExercises 11 and 12.14. Define DiscountPolicy as an interface instead of the abstract classdescribed in Exercise 10.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here