public static CashSuper CreateCashAccept(string type) { CashSuper cs; switch (type) { case "满300返100": cs = new CashReturn("300", "100"); break; case "打8折": cs = new CashRebate("0.8"); break; case "打7折": cs = new CashRebate("0.7"); break; case "打5折": cs = new CashRebate("0.5"); break; default: cs = new CashNormal(); break; } return(cs); }
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": CashReturn cashReturn = new CashReturn("300", "100"); cs = cashReturn; break; case "打八折": CashRebate cashRebate = new CashRebate("0.8"); cs = cashRebate; break; } return(cs); }
//根据条件返回相应的对象 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 "Normal charge": CashNormal c1 = new CashNormal(); _cashCharge = c1; break; case "300 minus 100": CashReturn c2 = new CashReturn("300", "100"); _cashCharge = c2; break; case "20% off": CashRebate c3 = new CashRebate("0.8"); _cashCharge = c3; break; default: throw new Exception("error"); } }
public static CashBase CreateCashAccept(string type) { CashBase cs = null; switch (type) { case "正常收费": cs = new CashNormal(); break; case "满300返100收费": cs = new CashReturn(300, 100); break; case "打折收费": cs = new CashRebate(0.8f); break; default: break; } return(cs); }
/// <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 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 void acceptCashTest(double rebate, double money) { CashRebate cashRebate = new CashRebate(rebate); Assert.Equal(cashRebate.acceptCash(money), rebate * money); }