Question: Thanks for the help. Implement the following interface and classes: IDiscountPolicy BulkDiscount BuyNItemsGetOneFree CombinedDiscount DiscountTester IDiscountPolicy is an interface. IDiscountPolicy has singe method computeDiscount. computeDiscount

Thanks for the help. Implement the following interface and classes: IDiscountPolicy BulkDiscountThanks for the help.

Implement the following interface and classes: IDiscountPolicy BulkDiscount BuyNItemsGetOneFree CombinedDiscount DiscountTester IDiscountPolicy is an interface. IDiscountPolicy has singe method computeDiscount. computeDiscount returns a double. The double represents the discount amount for a given number of items. computeDiscount has two parameters, int count indicates the number of items, double itemCost is the cost of a single item. BulkDiscount implements the IDiscountPolicy interface. The constructor has two parameters, int minimum specifies the minimum number of items need to get the discount, double percent is the discount percent. The computeDiscount method computes the discount amount as follows: if count = minimum then discount = count * itemCost * percent BuyNItemsGetOneFree implements the IDiscountPolicy interface. The constructor has one parameter: int n. n represents the numbers of items needed to get one item free. For example when n is 3, when buying 3 items one is free, when buying 6 items 2 are free. The computeDiscount method computes the discount as follows: discount = number of free items * itemCost CombinedDiscount implements the IDiscountPolicy interface. The constructor has two parameters of type IDiscountPolicy. The computeDiscount method computes the discount amount using the two IDiscountPolicy objects and returns the largest discount amount. The DiscountTester class tests the BulkDiscount, BuyNItemsGetOneFree and CombinedDiscount classes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!