Ejemplo n.º 1
0
 //根據條件返回相應的物件
 public CashContext(string type)
 {
     switch (type)
     {
     case "正常收費":
         CashNormal cs0 = new CashNormal();
         cs = cs0;
         break;
     case "滿300送100":
         CashReturn cr1 = new CashReturn("300", "100");
         cs = cr1;
         break;
     case "打8折":
         CashRebate cr2 = new CashRebate("0.8");
         cs = cr2;
         break;
     }
 }
Ejemplo n.º 2
0
        //根據條件返回相應的物件
        public CashContext(string type)
        {
            switch (type)
            {
            case "正常收費":
                CashNormal cs0 = new CashNormal();
                cs = cs0;
                break;

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

            case "打8折":
                CashRebate cr2 = new CashRebate("0.8");
                cs = cr2;
                break;
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 public void setBehavior(CashSuper csuper)
 {
     this.cs = csuper;
 }
Ejemplo n.º 5
0
 //設定策略行為,參數為具體的現金收費子類別(正常,打折或紅利)
 public CashContext(CashSuper csuper)
 {
     this.cs = csuper;
 }
Ejemplo n.º 6
0
 public void setBehavior(CashSuper csuper)
 {
     this.cs = csuper;
 }
Ejemplo n.º 7
0
 //設定策略行為,參數為具體的現金收費子類別(正常,打折或紅利)
 public CashContext(CashSuper csuper)
 {
     this.cs = csuper;
 }