示例#1
0
 public static CashSuper createCashAccept(string type)
 {
     CashSuper cs = null;
     switch (type)
     {
         case "正常收费":
             cs = new CashNormal();
             break;
         case "满300返100":
             CashReturn cr1 = new CashReturn("300", "100");
             cs = cr1;
             break;
         case "打8折":
             CashRebate cr2 = new CashRebate("0.8");
             cs = cr2;
             break;
     }
     return cs;
 }
        public CashContext(string type)
        {
            switch (type)
            {
            case "正常收費":
                var cs0 = new CashNormal();
                cs = cs0;
                break;

            case "滿300送100":
                var cr1 = new CashReturn("300", "100");
                cs = cr1;
                break;

            case "打8折":
                var cr2 = new CashRebate("0.8");
                cs = cr2;
                break;
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type">收费策略,而不是收费的对象</param>
        public CashContext(string type)
        {
            switch (type)
            {
            case "1":
                CashNormal cs0 = new CashNormal();    //实例化具体策略的过程由客户端转移到Context类中。简单工厂的应用
                cs = cs0;
                break;

            case "2":
                CashReturn cs1 = new CashReturn("300", "100");
                cs = cs1;
                break;

            case "3":
                CashRebate cs2 = new CashRebate("0.8");
                cs = cs2;
                break;
            }
        }
示例#4
0
        public static CashSuper createCashAccept(string type)
        {
            CashSuper cs = null;

            switch (type)
            {
            case "正常收費":
                cs = new CashNormal();
                break;

            case "滿300送100":
                cs = new CashReturn("300", "100");
                break;

            case "打8折":
                cs = new CashRebate("0.8");
                break;
            }
            return(cs);
        }
        public static CashSuper createCashAccept(string type)
        {
            CashSuper cashSuper = null;

            switch (type)
            {
            case "正常收費":
                cashSuper = new CashNormal();
                break;

            case "打8折":
                cashSuper = new CashRebate(0.8d);
                break;

            case "滿300送100":
                cashSuper = new CashReturn(300d, 100d);
                break;
            }

            return(cashSuper);
        }
        public static CashSuper createCashAccept(string type)
        {
            CashSuper cs = null;

            switch (type)
            {
            case "正常收费":
                cs = new CashNormal();
                break;

            case "满300返100":
                CashReturn cr1 = new CashReturn("300", "100");
                cs = cr1;
                break;

            case "打8折":
                CashRebate cr2 = new CashRebate("0.8");
                cs = cr2;
                break;
            }
            return(cs);
        }