Question: Java Question #2 40 points a) Create an abstract class DiscountPolicy. It should have a single abstract method computeDiscount that will return the discount from
Question #2 40 points a) Create an abstract class DiscountPolicy. It should have a single abstract method computeDiscount that will return the discount from the purchase of a given number of a single item. The method has two parameters, count and itemcost. b) Derive a class BuyNItemsGetoneFree from Discount Policy. It should have a constructor that has a single parameter n. The data member of this class will be n. In addition, the class should define the method computeDiscount so that every nth item is Eree. For example, if n is 3 and the customer buys 7 items and the cost of each item is $10, then the discount will be $20 since every 3rd item will be tree. It n is 4 and the cost of each item is $10 and if the user buys 7 items, then the discount will be $10. c) Create testing class 20 point
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
