Ejemplo n.º 1
0
 public Basket(DiscountType type)
 {
     this._strategy = BasketDiscountFactory.GetDiscount(type);
 }
 public Basket(DiscountType discountType)
 {
     _basketDiscount = BasketDiscountFactory.GetDiscount(discountType);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 通过构造函数实现创建具体的打折策略对象
 /// </summary>
 /// <param name="discountType"></param>
 public Basket(DiscountType discountType)
 {
     //根据枚举类型使用工厂方法创建指定的打折策略(都实现了IBasketDiscountStrategy接口)
     //实现了该接口的具体实现类中都实现了GetTotalCostAfterApplyingDiscountTo方法实现打折
     _basketDiscount = BasketDiscountFactory.GetDiscount(discountType);
 }
Ejemplo n.º 4
0
 public Basket(DiscountTypeEnum discountType)
 {
     _basketDiscountStrategy = BasketDiscountFactory.GetDiscount(discountType);
 }