public uint GetQuantity(ItemName name) { if (itemsDictionary.ContainsKey(name)) { return(itemsDictionary[name]); } else { return(0); } }
public Products DispenseProduct(string slotLocation) { if (!ItemsDictionary.ContainsKey(slotLocation)) { throw new Exception("This item does not exist"); } Products selectedProduct = ItemsDictionary[slotLocation]; if (selectedProduct.Quantity == 0) { throw new Exception("Item is out of stock"); } else { if (Balance < selectedProduct.Price) { throw new Exception("Balance insufficient for selected item"); } else { Balance -= selectedProduct.Price; //TotalAmountDue += selectedProduct.Price; selectedProduct.Quantity--; Console.WriteLine(selectedProduct.Message); //TODO: Create Audit StreamWriter for Log.txt } } return(selectedProduct); //TODO: This needs more, what do we want to happen/be said when the product dispenses }