public void Init() { i1 = new StockItem ("BMAC56790", "Propelling Pencil", "Supply Master", "1.49", "10", "20"); stock_list = new Stock(); stock_list.AddStockItem(i1.StockCode, i1); order_history = new OrderHistory(); DateTime timestamp = DateTime.Now; o1 = new Order (timestamp, i1.StockCode, i1.Supplier, 10, 10); order_history.AddOrder (o1); }
public bool PlaceOrder(string id, double cost, int quantity) { StockItem item = stock_list.FindItemByKey (id); if (cost <= BankAccount.Instance.AccountBalance && quantity > 0) { //Place the order double new_balance = BankAccount.Instance.AccountBalance - cost; BankAccount.Instance.AccountBalance = new_balance; item.StockLevel += quantity; DateTime timestamp = DateTime.Now; Order o = new Order (timestamp, id, item.Supplier, cost, quantity); order_history.AddOrder (o); return true; } else if (quantity == 0) { throw new NullReferenceException ("You can't order 0 items!"); } else return false; }
public void Init() { i1 = new StockItem ("BMAC56790", "Propelling Pencil", "Supply Master", "1.49", "10", "20"); o1 = new Order (timestamp, i1.StockCode, i1.Supplier, 10, 10); }