public CashContext(string type) { switch (type) { case "正常收費": cs = new CashNormal(); break; case "滿三百送一百": CashReturn cs1 = new CashReturn("300", "100"); cs = cs1; break; case "打八折": CashRebate cs2 = new CashRebate("0.8"); cs = cs2; break; } }
public static CashSuper createCashAccept(string type) { CashSuper cs = null; switch (type) { case "正常收費": cs = new CashNormal(); break; case "滿三百送一百": CashReturn cs1 = new CashReturn("300", "100"); cs = cs1; break; case "打八折": CashRebate cs2 = new CashRebate("0.8"); cs = cs2; break; } return(cs); }