示例#1
0
 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);
 }
示例#2
0
        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;
        }
示例#3
0
 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);
 }