Пример #1
0
        /// <summary>
        /// 简单工厂构造函数(这里是简单策略模式和简单工厂模式结合的关键点)
        /// </summary>
        /// <param name="rebateType">商场促销类型</param>
        public CashContext(string rebateType)
        {
            switch (rebateType)
            {
            case "不打折":
                this.cs = new CashNormal();
                break;

            case "打八折":
                this.cs = new CashRebate(0.8);
                break;

            case "满三百送一百":
                this.cs = new CashReturn(300, 100);
                break;
            }
        }
Пример #2
0
 /// <summary>
 /// 普通构造函数
 /// </summary>
 /// <param name="cs">商场促销实例对象</param>
 public CashContext(CashSuper cs)
 {
     this.cs = cs;
 }