Exemplo n.º 1
0
        private void PurchaseStock(InventoryItems item, List <InventoryItems> itemType)
        {
            int purchaseNumber;

            purchaseNumber = GetTransactionChoice(item);
            if (CheckFunds(item.Cost, purchaseNumber))
            {
                FinalizeTransaction(item, purchaseNumber, itemType);
            }
            else
            {
                Console.WriteLine("insufficient funds please choose a different amount");
                PurchaseStock(item, itemType);
                return;
            }
        }
Exemplo n.º 2
0
        private int GetTransactionChoice(InventoryItems item)
        {
            int userInput;

            Console.WriteLine($"{item.Name}(s) costs {item.Cost} shillings\nHow many would you like to buy?\nCurrent funds: {inventory.Money} shillings");
            try
            {
                userInput = int.Parse(Console.ReadLine());
            }
            catch (Exception)
            {
                Console.WriteLine($"Input not recognized please type in an integer");
                userInput = GetTransactionChoice(item);
                return(userInput);
            }
            return(userInput);
        }
Exemplo n.º 3
0
 private void DisplayItemInfo(InventoryItems item)
 {
     Console.WriteLine($"{item.Name}\nCost: {item.Cost}\nShelf Life: {item.ShelfLife}");
 }