Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedThanks 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

Explain the different types of marketing strategies.

Answered: 1 week ago

Question

Explain product positioning.

Answered: 1 week ago

Question

Explain Industrial market segment.

Answered: 1 week ago