Beispiel #1
0
 /// <summary>
 /// strategy+factory
 /// </summary>
 /// <param name="type"></param>
 public CashContext(string type, double moneyRebate = 1, double moneyCondition = 300, double moneyReturn = 100)
 {
     fStragtegy = type switch
     {
         "Normal" => new CashNormal(),
         "Rebate" => new CashRebate(moneyRebate),
         "Return" => new CashReturn(moneyCondition, moneyReturn),
         _ => throw new Exception("不知名的外星人")
     };
 }
Beispiel #2
0
 /// <summary>
 /// strategy
 /// </summary>
 /// <param name="strategy"></param>
 public CashContext(ICashStrategy strategy)
 {
     fStragtegy = strategy;
 }