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; } }
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; } }
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; } }
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; } }
//单独策略模式 //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; } }
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; } }
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; } }
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; } }
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); }
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); }
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; } }
/// <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); }
public CashContext(CashSuper cash) { this.cash = cash; }
//设置策略行为,参数为具体的现金收费子类(正常,打折或返利) //这个是构造函数!用来接收具体策略的! public CashContext(CashSuper csuper) { this.cs = csuper; }
public void setBehavior(CashSuper csuper) { this.cs = csuper; }
public CashContext(CashSuper cashSuper) { _cashSuper = cashSuper; }
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; } }
public CashContext(CashSuper csuper) { this.cs = csuper; }