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