Hi all I want to develop a system that is similar to calculation of salary. A salary has a basic value. On top of it, an employee can get some Bonus (es) or Penalties. Decorator Pattern seems to fit this scenario
Salary finalSalary = new HardworkBonus(new LateComingPenalty(new BasicSalary()))
System.out.println("Your total salary is : "+ finalSalary.calculate())
In addition, I want to save the result of each computation. So in the end, even after calculation, I can retrieve how much was the LateComingPenalty.
It seems to be a common problem where such sort of invoice calculations is involved.There might be some better options than Decorator Pattern.Do you have some better suggestions?