コード例 #1
0
ファイル: CashContext.cs プロジェクト: qcjwq/DesignPatterns
 public CashContext(string type)
 {
     switch (type)
     {
         case "打八折":
             _cashSuper = new CashRebate("0.8");
             break;
         case "满300返100":
             _cashSuper = new CashReturn("300", "100");
             break;
         default:
             _cashSuper = new CashNormal();
             break;
     }
 }
コード例 #2
0
ファイル: CashContext.cs プロジェクト: Jeffiy/DesignPatterns
 public CashContext(string type)
 {
     switch (type)
     {
         case "满300减100":
             _cashSuper = new CashRetrun(300, 100);
             break;
         case "打8折":
             _cashSuper = new CashRebate(0.8);
             break;
         case "正常收费":
         default:
             _cashSuper = new CashNormal();
             break;
     }
 }
コード例 #3
0
ファイル: CashContext.cs プロジェクト: xin-wei/DesignMode
        public CashContext(string type)
        {
            switch (type)
            {
                case "Normal":
                    cs = new CashNormal();
                    break;

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

                case "0.8":
                    cs = new CashRebate("0.8");
                    break;
            }
        }
コード例 #4
0
ファイル: CashContext.cs プロジェクト: xin-wei/DesignMode
        public CashContext(string type)
        {
            switch (type)
            {
            case "Normal":
                cs = new CashNormal();
                break;

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

            case "0.8":
                cs = new CashRebate("0.8");
                break;
            }
        }
コード例 #5
0
ファイル: CashContext.cs プロジェクト: qcjwq/DesignPatterns
        public CashContext(string type)
        {
            switch (type)
            {
            case "打八折":
                _cashSuper = new CashRebate("0.8");
                break;

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

            default:
                _cashSuper = new CashNormal();
                break;
            }
        }
コード例 #6
0
    public CashContextFactory(string type)
    {
        switch (type)
        {
        case "Normal":
            cs = new CashNormal();
            break;

        case "80% discount":
            cs = new CashRebate("0.8");
            break;

        case "300 Return 100":
            cs = new CashReturn("300", "100");
            break;
        }
    }
コード例 #7
0
        //单独策略模式
        //public CashContext(CashSuper csuper)
        //{
        //    this.cs = csuper;
        //}

        //策略模式与简单工厂模式相结合
        public CashContext(string type)
        {
            switch (type)
            {
            case "正常收费":
                cs = new CashNormal();
                break;

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

            case "打8折":
                cs = new CashRebate("0.8");
                break;
            }
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: imkcrevit/DesignPattern
            public CashFactory(string type)
            {
                ce = null;
                switch (type)
                {
                case "正常收费":
                    ce = new CashNormal();
                    break;

                case "满300-30":
                    ce = new CashReturn("300", "30");
                    break;

                case "打八折":
                    ce = new CashRebate("0.8");
                    break;
                }
            }
コード例 #9
0
    public CashContext(string type)
    {
        //simple factory pattern
        switch (type)
        {
        case "normal":
            cs = new CashNormal();
            break;

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

        case "cashRebate":
            cs = new CashRebate(0.8);
            break;
        }
    }
コード例 #10
0
        public CashContext(string type)
        {
            switch (type)
            {
            case "满300减100":
                _cashSuper = new CashRetrun(300, 100);
                break;

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

            case "正常收费":
            default:
                _cashSuper = new CashNormal();
                break;
            }
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: AtchisonAI/Cashier
            public CashContext(string type)
            {
                switch (type)
                {
                case "正常收费":
                    CashNorml cs0 = new CashNorml();
                    cs = cs0;
                    break;

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

                case "打8折":
                    CashRebate cs2 = new CashRebate("0.8");
                    cs = cs2;
                    break;
                }
            }
コード例 #12
0
    public static CashSuper createCashAccept(string type)
    {
        CashSuper cs = null;

        switch (type)
        {
        case "Normal":
            cs = new CashNormal();
            break;

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

        case "80% discount":
            cs = new CashRebate("0.8");
            break;
        }
        return(cs);
    }
コード例 #13
0
ファイル: CashFactory.cs プロジェクト: luutry/DesignPattern
        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 "打八折":
                cs = new CashRebate("0.8");
                break;
            }
            return(cs);
        }
コード例 #14
0
        public CashContext(string rule)
        {
            switch (rule)
            {
            case "Regular":
                cs = new CashRegular();
                break;

            case "Rebate 20%":
                cs = new CashRebate("0.8");
                break;

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

            default:
                cs = new CashRegular();
                break;
            }
        }
コード例 #15
0
        /// <summary>
        /// 收费对象生成工厂
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static CashSuper CreateCashAccecpt(string type)
        {
            CashSuper cashSuper = null;

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

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

            case "满200减10":
                cashSuper = new CashReturn("200", "10");
                break;

            default:
                break;
            }
            return(cashSuper);
        }
コード例 #16
0
 public CashContext(CashSuper cash)
 {
     this.cash = cash;
 }
コード例 #17
0
 //设置策略行为,参数为具体的现金收费子类(正常,打折或返利)
 //这个是构造函数!用来接收具体策略的!
 public CashContext(CashSuper csuper)
 {
     this.cs = csuper;
 }
コード例 #18
0
 public void setBehavior(CashSuper csuper)
 {
     this.cs = csuper;
 }
コード例 #19
0
ファイル: Program.cs プロジェクト: imkcrevit/DesignPattern
 public CashContext(CashSuper cashSuper)
 {
     _cashSuper = cashSuper;
 }
コード例 #20
0
 public CashContextFactory(string type)
 {
     switch(type){
         case "Normal":
             cs = new CashNormal();
             break;
         case "80% discount":
             cs = new CashRebate("0.8");
             break;
         case "300 Return 100":
             cs = new CashReturn("300", "100");
             break;
     }
 }
コード例 #21
0
 public CashContext(CashSuper csuper)
 {
     this.cs = csuper;
 }