Ejemplo n.º 1
0
        //Card or Coin
        public static string ChoosePaymentMethod()
        {
            Console.WriteLine("Enter 1 to pay with card, Enter 2 to pay with coins: ");
            string userInput         = Console.ReadLine();
            string verifiedUserInput = Verification.VerifyUserInput(userInput, 1, 2);

            return(verifiedUserInput);
        }
Ejemplo n.º 2
0
        //Customer chooses a soda
        public static string MakeSelection(SodaMachine sodaMachine, string paymentMethod)
        {
            Console.WriteLine("Please make a selection: \n");
            sodaMachine.DisplayCurrentInventory();
            string userInput;
            string verifiedUserInput;

            if (paymentMethod == "1") // Display if card payment
            {
                Console.Write("Select a soda: ");
                userInput         = Console.ReadLine();
                verifiedUserInput = Verification.VerifyUserInput(userInput, 1, 3); // Only allow customer to choose a soda
            }
            else // Display if coin payment
            {
                Console.Write("\nSelect a soda, or enter 0 to insert more coins: ");
                userInput         = Console.ReadLine();
                verifiedUserInput = Verification.VerifyUserInput(userInput, 0, 3); // Allow customer to choose to input more coins
                if (verifiedUserInput == "0")                                      // Return to prompt interface to enter more coins
                {
                    return(verifiedUserInput);
                }
            }
            bool canExists = false;

            while (!canExists)
            {
                switch (verifiedUserInput)
                {
                case "1":
                    canExists = Verification.CheckIfObjectExists(sodaMachine.inventory, "Cola");
                    break;

                case "2":
                    canExists = Verification.CheckIfObjectExists(sodaMachine.inventory, "Orange Soda");
                    break;

                case "3":
                    canExists = Verification.CheckIfObjectExists(sodaMachine.inventory, "Root Beer");
                    break;
                }
                if (!canExists) // Prompt to make another choice if soda their is sold out
                {
                    Console.WriteLine("This soda is sold out. Please make another selection.");
                    userInput         = Console.ReadLine();
                    verifiedUserInput = Verification.VerifyUserInput(userInput, 1, 3);
                }
            }
            return(verifiedUserInput);
        }
Ejemplo n.º 3
0
        //Give option to purchase again
        //run simulation again
        public bool RunSimulationAgain()
        {
            bool runAgain;

            Console.Write("\nWould you like to purchase another soda?\nType 1 for yes, Type 2 to end simulation: ");
            string userInput         = Console.ReadLine();
            string verifiedUserInput = Verification.VerifyUserInput(userInput, 1, 2);

            if (verifiedUserInput == "1")
            {
                runAgain = true;
                return(runAgain);
            }
            else
            {
                runAgain = false;
                return(runAgain);
            }
        }
Ejemplo n.º 4
0
        //Insert user payment
        public void InsertPayment(SodaMachine sodaMachine)
        {
            DisplayContents(wallet);
            Console.WriteLine("\nType 1 to insert quarter\nType 2 to insert dime\nType 3 to insert nickel\nType 4 to insert penny");
            string userInput         = Console.ReadLine();
            string verifiedUserInput = Verification.VerifyUserInput(userInput, 1, 4);
            Coin   insertedCoin      = null;

            while (insertedCoin == null)
            {
                switch (verifiedUserInput)
                {
                case "1":
                    bool coinExists = Verification.CheckIfObjectExists(wallet.coins, "Quarter");
                    if (coinExists)
                    {
                        for (int i = 0; i < wallet.coins.Count; i++)
                        {
                            if (wallet.coins[i].name == "Quarter")
                            {
                                insertedCoin = wallet.coins[i];
                                wallet.coins.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("You do not have any quarters to insert. Choose another coin.");
                        userInput         = Console.ReadLine();
                        verifiedUserInput = Verification.VerifyUserInput(userInput, 1, 4);
                        break;
                    }
                    break;

                case "2":
                    coinExists = Verification.CheckIfObjectExists(wallet.coins, "Dime");
                    if (coinExists)
                    {
                        for (int i = 0; i < wallet.coins.Count; i++)
                        {
                            if (wallet.coins[i].name == "Dime")
                            {
                                insertedCoin = wallet.coins[i];
                                wallet.coins.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("You do not have any dimes to insert. Choose another coin.");
                        userInput         = Console.ReadLine();
                        verifiedUserInput = Verification.VerifyUserInput(userInput, 1, 4);
                        break;
                    }
                    break;

                case "3":
                    coinExists = Verification.CheckIfObjectExists(wallet.coins, "Nickel");
                    if (coinExists)
                    {
                        for (int i = 0; i < wallet.coins.Count; i++)
                        {
                            if (wallet.coins[i].name == "Nickel")
                            {
                                insertedCoin = wallet.coins[i];
                                wallet.coins.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("You do not have any nickels to insert. Choose another coin.");
                        userInput         = Console.ReadLine();
                        verifiedUserInput = Verification.VerifyUserInput(userInput, 1, 4);
                        break;
                    }
                    break;

                case "4":
                    coinExists = Verification.CheckIfObjectExists(wallet.coins, "Penny");
                    if (coinExists)
                    {
                        for (int i = 0; i < wallet.coins.Count; i++)
                        {
                            if (wallet.coins[i].name == "Penny")
                            {
                                insertedCoin = wallet.coins[i];
                                wallet.coins.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("You do not have any pennies to insert. Choose another coin.");
                        userInput         = Console.ReadLine();
                        verifiedUserInput = Verification.VerifyUserInput(userInput, 1, 4);
                        break;
                    }
                    break;
                }
            }
            sodaMachine.hopperIn.Add(insertedCoin);
        }