Our new customer asked us to write a system of bonuses for his store customers with the possibility of using various bonus-calculation strategies.
To implement the project, we've created:
1. The BonusCalculator interface, which contains the following function:
calculateBonus(spend: Double): Double– it calculates the number of bonus points awarded depending on the amount spent.
2. Two classes that implement the BonusCalculator interface:
FlatRateBonusCalculator– it gives a fixed number of bonus points for every $100 spent.PercentageBonusCalculator– it gives bonus points as a percentage of the amount spent.
You need to create the Customer class, which uses class delegation to calculate bonuses using BonusCalculator.