| public double calculateCommission( Trade trade ) { return 20.0; } 类名: PricingPlan1510 public double calculateCommission( Trade trade ) { double commission = 0.0; if( trade.getCustomer().getNumberOfTradesThisMonth() <= 10 ) commission = 15.0; else commission = 10.0; return commission; } |
| public double getCommissionPrice() { double commissionPrice = 0.0; if( getCustomer().getPlanId() == 1 ) { PricingPlan20 plan1 = new PricingPlan20(); commissionPrice = plan1.calculateCommission( this.getCustomer() ); plan1 = null; } else { PricingPlan1510 plan2 = new PricingPlan1510(); commissionPrice = plan2.calculateCommission( this.getCustomer() ); plan2 = null; } return commissionPrice; } |