/// <summary> /// Sells item assigned to <paramref name="key"/> and subtracts it from CurrentBalance. /// </summary> /// <param name="key">Key in Inventory represented by slot code</param> public void ProductSelect(string key) { Log.WriteProductSelect(this, key); MachineItem mi = Inventory[key]; if (!mi.SoldOut) { if (mi.Price <= CurrentBalance) { mi.Qty -= 1; CurrentBalance -= mi.Price; _purchaseList.Add(mi); Report.ReportDict[mi.Name]++; Report.AddToTotal(mi.Price); } else { throw new InsufficientFundsException(); } } else { throw new SoldOutException(); } }
/// <summary> /// Sells item assigned to <paramref name="key"/> and subtracts it from CurrentBalance. /// </summary> /// <param name="key">Key in Inventory represented by slot code</param> public void ProductSelect(string key) { MachineItem mi = Inventory[key]; if (!mi.SoldOut) { if (mi.Price <= CurrentBalance) { mi.Qty -= 1; CurrentBalance -= mi.Price; _purchaseList.Add(mi); Report.ReportDict[mi.Name]++; Report.AddToTotal(mi.Price); } else { throw new InvalidOperationException(); } } else { throw new Exception(); } }