public void PurchaseItem(string location)
 {
     PurchasedItems.Add(GetItemFromSlot(location));
     Trans.TotalPurchasePrice += 100 * GetItemFromSlot(location).Price;
     log.PrintLog(log.PrintPurchase(GetItemFromSlot(location).Name, GetItemFromSlot(location).Price, Trans.BalanceInDollars));// purchase log
     Slots[location].RemoveItem();
 }
Пример #2
0
        public void PurchaseItem(string location)
        {
            if (!Slots.ContainsKey(location))
            {
                throw new VendingMachineException("Invalid slot selection.");
            }
            if (Slots[location].IsEmpty)
            {
                throw new VendingMachineException("Item out of stock.");
            }
            if (Slots[location].Price > Trans.BalanceInDollars)
            {
                throw new VendingMachineException("Not enough money provided.");
            }

            PurchasedItems.Add(GetItemFromSlot(location));
            Trans.TotalPurchasePriceInPennies += 100 * GetItemFromSlot(location).Price;
            log.PrintPurchase(GetItemFromSlot(location).Name, GetItemFromSlot(location).Price, Trans.BalanceInDollars);// purchase log
            Slots[location].RemoveItem();
        }