Derive a class BuyNItemsGetOneFree from DiscountPolicy, as described in Exercise 10. The class should have a constructor that has a single parameter n. In addition, the class should define the method...


Derive a class BuyNItemsGetOneFree from DiscountPolicy, as described
in Exercise 10. The class should have a constructor that has a single
parameter n. In addition, the class should define the method
computeDiscount so that every nth item is free. For example, the followingtable gives the discount for the purchase of various counts of an item that
costs $10, when n is 3:
Count 1 2 3 4 5 6 7
Discount 0 0 10 10 10 20 20
13. Derive a class CombinedDiscount from DiscountPolicy, as described in
Exercise 10. It should have a constructor that has two parameters of type
DiscountPolicy. It should define the method computeDiscount to return
the maximum value returned by computeDiscount for each of its two
private discount policies. The two discount policies are described in
Exercises 11 and 12.
14. Define DiscountPolicy as an interface instead of the abstract class
described in Exercise 10.



Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here