CJCoding With Joseph

Discount Strategies

Build an interface-based strategy from scratch. Define an interface IDiscount with a method int Apply(int price). Then define two classes that implement it:
- PercentOff(int percent) whose Apply returns price - price * percent / 100
- FlatOff(int amount) whose Apply returns price - amount
The tester applies each strategy to a price of 200. Do NOT write a Main method.

For PercentOff(10) then FlatOff(15) on 200 the program prints:
180
185

Expected Output:

180
185
Topics:
Polymorphism
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.