public void DispenseItem(string position)
        {
            // User selects valid position
            if (Stock.ContainsKey(position))
            {
                // There is at least one item within the position
                if (Stock[position].Count != 0)
                {
                    // Call Transaction Class --> Make purchase Method

                    // Add item to List of purchased items in the transaction
                    if (transaction.MakePurchase(Stock[position][0].Cost))
                    {
                        PurchasedItems.Add(Stock[position][0]);
                        TotalPurchasedItems.Add(Stock[position][0]);

                        fileIO.LogTransaction(Stock[position][0].Name, position, Stock[position][0].Cost, Balance);
                        Console.WriteLine($"{Stock[position][0].Name} purchased!");

                        // Remove an item from the Dictionary's stock
                        Stock[position].RemoveAt(0);
                    }
                }
                // There is no inventory left
                else
                {
                    // Tell user out of stock
                    Console.WriteLine($"{position} is out of stock.");
                }
            }
            // User entered invalid position
            else
            {
                // Tell user invalid position
                Console.WriteLine($"Please enter a valid position.");
            }
        }
Exemple #2
0
 private bool IsInStockAndHaveTender(string nomNom)
 {
     return(Stock.ContainsKey(nomNom) && Stock[nomNom].Count != 0 && tenderAmount >= Stock[nomNom][0].Price);
 }
Exemple #3
0
 private bool IsInStockWithInsufficientTender(string nomNom)
 {
     return(Stock.ContainsKey(nomNom) && Stock[nomNom].Count != 0 && Stock[nomNom][0].Price > tenderAmount);
 }
Exemple #4
0
 private bool IsOutOfStockItem(string nomNom)
 {
     return(Stock.ContainsKey(nomNom) && Stock[nomNom].Count == 0);
 }