public class Order { public final static int FIXED_AMOUNT_COMMISION = 1; public final static int FIXED_PERCENT_COMMISION = 2; private BigDecimal quantity, price; private int commisionType; public Order(BigDecimal quantity, BigDecimal price, int commisionType) { this.quantity = quantity; this.price = price; this.commisionType = commisionType; } public BigDecimal getQuantity(){return quantity;} public BigDecimal getPrice() {return price;} public void setQuantity(BigDecimal quantity) { this.quantity = quantity; } public void setPrice(BigDecimal price) { this.price = price; } public BigDecimal calculateCommesion(){ switch (commisionType){ case FIXED_AMOUNT_COMMISION: return new BigDecimal("200.00"); case FIXED_PERCENT_COMMISION: return getQuantity().multiply(getPrice()).multiply(new BigDecimal(0.10)); } return new BigDecimal(0.00); } //other data and methods } It is necessary to change the design of the code so that it meets the following criteria:
- it is easy to add new types of commission and their calculus in the system without changing the class Order
- the ability to change the type of commission of this order after its creation;
- add the 3rd type of commission according to the following criteria:
- if the amount is greater than this threshold (set for each instruction separately) the commission is 50.00;
- otherwise, the commission is 100.00;
- Remove all firmly given numbers and replace them with parameters.