/// <summary> /// load cash for work /// </summary> /// <param name="filePath">cash log file</param> private void LoadCash(string filePath) { if (File.Exists(filePath)) { BinaryReader reader = new BinaryReader(File.Open(filePath, FileMode.Open)); try { while (reader.BaseStream.Length != reader.BaseStream.Position) { int key = reader.ReadInt32(); ICash cash = (ICash)Activator.CreateInstance( Type.GetType(reader.ReadString())); cash.Amount = reader.ReadDouble(); this.cash.Add((Currency)key, cash); } } catch (Exception e) { throw new ArgumentException(e.Message); } finally { reader.Close(); } } else { throw new ArgumentNullException("file does not exists"); } }
public void Remove(ICash denomination, int amount) { bool exists = CashStack.TryGetValue(denomination, out int value); if (exists) { CashStack[denomination] = value - amount; } }
public IndexModel(ICar car, ICapitalShare capitalShare, IAfterSellExpncess afterSellExpncess, ICheck check, ICash cash) { this.car = car; this.afterSellExpncess = afterSellExpncess; this.capitalShare = capitalShare; this.check = check; this.cash = cash; model = new outputModel(); }
public mantainModel(IBuyRecords buyRecords, IOutcome outcome, ICash cash, IIncome income, ISellrecord sellrecord, IAfterBuyExpncess afterBuyExpncess, IAfterSellExpncess afterSellExpncess) { this.buyRecords = buyRecords; this.sellrecord = sellrecord; this.afterBuyExpncess = afterBuyExpncess; this.afterSellExpncess = afterSellExpncess; this.income = income; this.cash = cash; this.outcome = outcome; }
/// <summary> /// Add cash to account /// </summary> /// <param name="id">Account ud</param> /// <param name="currency">New cash currency</param> /// <param name="cash">Cash type</param> public void AddCash(string id, Currency currency, ICash cash) { Account tmp = _storage.GetAccountById(id); if (tmp.AddCash(currency, cash)) { _storage.UpdateAccount(tmp); Notify(tmp, string.Format("You have successfully added new {0} cash", currency)); } }
/// <summary> /// add new cash /// </summary> /// <param name="key">enumerable cash representation</param> /// <param name="cash">cash kind</param> public void AddCash(Currency key, ICash cash) { if (!this.cash.ContainsKey(key)) { this.cash[key] = cash; } else { throw new ArgumentException(string.Format("cash {0} already exists", key)); } }
public CreditCard(Type cash) { if (cash == typeof(KakaoAccount)) { this.cash = new KakaoAccount(); } else if (cash == typeof(UriAccount)) { this.cash = new UriAccount(); } }
public SaleModel(ICar car, IManufacture manufacture, Ifile file, ISale sale, ISellrecord sellrecord, IIncome income, ICash cash, ICheck check, ICustomer customer) { this.car = car; this.manufacture = manufacture; _file = file; _sale = sale; this.sellrecord = sellrecord; this.income = income; this.cash = cash; this.check = check; this.customer = customer; }
/// <summary> /// Adds the given amount to this entry. /// If no matching entry exists, one will be created /// </summary> /// <param name="denomination">The denomination to adjust</param> /// <param name="amount">The amount of this denomination to add (use negative values to subtract)</param> public void Edit(ICash denomination, int amount) { bool exists = CashStack.TryGetValue(denomination, out int value); if (exists) { CashStack[denomination] = value + amount; } else { CashStack.Add(denomination, amount); } }
public void CanMakeSingleTypeLimitedCashSet(decimal value) { CashSet cashSet = (CashSet)CashController.SmallestSetForValue(value, Mocks.MockCashSets.StandardSet); ICash item = (from cashItem in cashSet.CashStack where cashItem.Key.UnitValue == value select cashItem.Key).FirstOrDefault(); cashSet.CashStack.TryGetValue(item, out int amount); Assert.AreEqual(1, amount); }
/// <summary> /// change existing cash /// </summary> /// <param name="key">enumerable cash representation</param> /// <param name="cash">cash kind</param> public void ChangeCash(Currency key, ICash cash) { if (this.cash.ContainsKey(key)) { double tempAmount = this.cash[key].Amount; this.cash[key] = cash; Replenish(key, tempAmount); } else { throw new ArgumentNullException(string.Format("cash {0} does not exists", key)); } }
/// <summary> /// 簡單工廠pattern /// </summary> /// <returns></returns> public static ICash CreateCashFactory(CashType cashType) { ICash instance = cashType switch { CashType.Normal => new CashNormal(), CashType.Rebate => new CashRebate(0.8), CashType.Return => new CashReturn(300, 100), _ => throw new Exception("不知名外星人") }; return(instance); } }
public buyAcarModel(IHostingEnvironment hostingEnv, ICheck incomes, IManufacture manufacture, IOutcome outcome, ICar car, IBuy buy, ICash cash, ICheck check, IBuyRecords buyrecord, Iperson saleperson, Ifile file) { _incomes = incomes; _hostingEnv = hostingEnv; _manufacture = manufacture; _outcome = outcome; _car = car; _buy = buy; _cash = cash; _check = check; _buyrecord = buyrecord; _saleperson = saleperson; _file = file; }
private void AppendMoney(Cash aMoney) { ICash old = FindMoney(aMoney.Currency); if (old == null) { fMonies.Add(aMoney); return; } fMonies.Remove(old); ICash sum = old.Add(aMoney); if (sum.IsZero) { return; } fMonies.Add(sum); }
/// <summary> /// Adds a new denomination of money to this drawer /// </summary> /// <param name="denomination">The type of cash to add</param> /// <param name="amount">(optional) The initial amount of this item to add (default: 0)</param> public void Add(ICash denomination, int amount = 0) { Edit(denomination, amount); }
public ICash AddMoneyBag(ICash s) { return((new CashBag((Cash)s, this)).Simplify()); }
public ICash Add(ICash m) { return(m.AddMoneyBag(this)); }
/// <summary> /// Add cash to account /// </summary> /// <param name="id">Account ud</param> /// <param name="currency">New cash currency</param> /// <param name="cash">Cash type</param> public void AddCash(string id, Currency currency, ICash cash) { _storage.GetAccountById(id).AddCash(currency, cash); }
public void ChangeContent(ICash cashItem, int difference) { DrawerContent.Edit(cashItem, difference); }
public ICash Subtract(ICash m) { return(Add(m.Negate())); }
public ValuesController(ICash car) { this.Cash = car; }
public ICash AddMoneyBag(ICash s) { return(s.AddMoney(this)); }