使用策略模式新增一种策略,允许在满100减20的基础上对Prime会员再打七折。
Topic sourcepublic class OverAndPrime implements DiscountStrategy{
@Override
public BigDecimal getDiscount(BigDecimal total) {
return new PrimeDiscountStrategy().getDiscount(total.subtract(new OverDiscountStrategy().getDiscount(total))).add(new OverDiscountStrategy().getDiscount(total));
}
}
- 1
Dominga丶