//public Context(PayCash payCash, CashEnum Mode) public Context(CashEnum Mode) { //this.payCash = payCash; switch (Mode) { case CashEnum.normal: payCash = new CashNormal(); break; case CashEnum.refund: payCash = new CashReturn("300", "100"); break; case CashEnum.discount: payCash = new CashDiscount("0.8"); break; default: break; } }
public static PayCash createCashAccept(CashEnum cashEnum) { PayCash payCash = null; switch (cashEnum) { case CashEnum.normal: payCash = new CashNormal(); break; case CashEnum.refund: payCash = new CashReturn("300", "100"); break; case CashEnum.discount: payCash = new CashDiscount("0.8"); break; default: break; } return(payCash); }