The problem proposed here can be solved with the strategy pattern. This design pattern defines a family of algorithms and makes them interchangeable within the family. In this particular problem, both the discounts and the final order price calculators could be implemented based on the strategy pattern. The following diagram describes the hierarchy of discount types and their interchangeable use within the other classes, customer, article, order_line, and order:
The implementation of the discount types is shown here:
struct discount_type{ virtual double discount_percent( double const price, double const ...