public void MenuOne()
        {
            Console.WriteLine("(1) Display Vending Machine Items");
            Console.WriteLine("(2) Purchase");
            Console.WriteLine("(3) End");
            Console.WriteLine();

            string answer = Console.ReadLine();

            Console.WriteLine();

            switch (answer)
            {
            case "1":
                Console.WriteLine(vendingMachine.Display());
                Console.WriteLine();
                break;

            case "2":
                SelectedMenuTwo = true;
                break;

            case "3":
                Done = true;
                break;

            case "9":
                vendingMachine.PrintSalesReport();
                break;

            default:
                Console.WriteLine("Invalid input, please try again.");
                break;
            }
        }
Beispiel #2
0
        public virtual void Menu()
        {
            Product        product        = new Product();
            List <Product> products       = new List <Product>();
            VendingMachine vendingMachine = new VendingMachine();
            bool           shouldContinue = false;

            do
            {
                Console.WriteLine();
                Console.WriteLine("Welcome to Vendo-Matic 3000!");
                Console.WriteLine();
                Console.WriteLine("1. Display Products");
                Console.WriteLine("2. Purchase");
                Console.WriteLine("3. Exit");
                string selection = Console.ReadLine();
                try
                {
                    Purchase purchase = new Purchase();
                    if (selection == "1")
                    {
                        vendingMachine.Display();
                        shouldContinue = true;
                    }
                    else if (selection == "2")
                    {
                        purchase.Menu();
                        shouldContinue = true;
                    }
                    else if (selection == "3")
                    {
                        shouldContinue = false;
                        return;
                    }
                    else if (selection == "4")
                    {
                        //SalesReport();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Enter a valid number please");
                }
            } while (shouldContinue);
        }
        public void Menu()
        {
            VendingMachine test = new VendingMachine();
            test.Start();
            bool main = true;
            bool purchase = true;
            //introduction
            Console.WriteLine("Welcome to the Vendo-Matic 600 (By Umbrella Corp.)");
            //options
            Console.WriteLine();
            while (main)
            {
                Console.Clear();
                Console.WriteLine("Main Menu - Please Select A Menu");
                Console.WriteLine();
                Console.WriteLine("1. Display Items");
                Console.WriteLine("2. Purchase Items");
                Console.WriteLine("3. Exit");
                string menuSelect = Console.ReadLine();
                if (menuSelect == "1")
                {
                    Console.Clear();
                    test.Display();
                    Console.WriteLine();
                    Console.WriteLine("Press any key to return");
                }
                else if (menuSelect == "2")
                {
                    while (purchase)
                    {
                        Console.Clear();
                        Console.WriteLine("Please Deposit Money");
                        test.Feed();
                        Console.WriteLine();
                        Console.WriteLine($"Your Total Amount Is {test.WalletValue}");
                        Console.WriteLine();
                        Console.WriteLine("Would You Like To Add More? Y/N ");
                        Console.WriteLine();
                        string answer = Console.ReadLine();
                        if (answer.ToLower() == "y")
                        {
                            continue;
                        }
                        else if (answer.ToLower() == "n")
                        {
                            Console.Clear();
                            Console.WriteLine("Please Select Your Item");
                            test.Purchase();
                            Console.WriteLine($"Your Remaining Balance is {test.WalletValue}");
                            Console.WriteLine();
                            Console.WriteLine("Would You Like To Make Another Purchase? Y/N");
                            string answer2 = Console.ReadLine();

                            if (answer2.ToLower() == "y")
                            {
                                continue;
                            }
                            else if (answer2.ToLower() == "n")
                            {
                                Console.Clear();
                                Console.WriteLine($"Your Change is {test.WalletValue}");
                                Console.WriteLine();
                                Console.ReadKey();
                                test.EndTransaction();
                                
                                break;
                            }
                        }
                        else
                        {
                            test.Error();
                        }
                        
                    }
                }
                else if (menuSelect == "3")
                {
                    break;
                 
                }
                else if (menuSelect == "4")
                {
                    test.SalesReport();
                    break;
                }
                else
                {
                    Console.WriteLine("Invalid Command, Please Select A Menu");
                }
            }

            Console.WriteLine("Thank you for Using the Vendo-Matic 600 (By Umbrella Corp.) GoodBye");
            Console.ReadKey();
        }
        public void Menu()
        {
            VendingMachine test = new VendingMachine();

            test.Start();
            bool main     = true;
            bool purchase = true;

            //introduction
            Console.WriteLine("Welcome to the Vendo-Matic 600 (By Umbrella Corp.)");
            //options
            Console.WriteLine();
            while (main)
            {
                Console.WriteLine("Main Menu - Please Select A Menu");
                Console.WriteLine();
                Console.WriteLine("1. Display Items");
                Console.WriteLine("2. Purchase Items");
                Console.WriteLine("3. Exit");

                string menuSelect = Console.ReadKey().ToString();
                switch (menuSelect)
                {
                case "1":
                    test.Display();
                    break;

                case "2":
                {
                    while (purchase)
                    {
                        Console.WriteLine("Purchase Menu - Please Select A Menu");
                        Console.WriteLine("1. Feed Money");
                        Console.WriteLine("2. Select Product");
                        Console.WriteLine("3. Recieve Change And Exit");
                        string purchaseSelect = Console.ReadLine();
                        if (purchaseSelect == "1")
                        {
                            Console.WriteLine("Please Insert An Amount");
                            Console.WriteLine("1. $1.00");
                            Console.WriteLine("2. $5.00");
                            Console.WriteLine("3. $10.00");
                            string moneyEntered = Console.ReadKey().ToString();
                            test.Feed(moneyEntered);
                            Console.WriteLine($"Your Total Amount Is {test.Wallet}");
                        }
                        else if (purchaseSelect == "2")
                        {
                            test.Display();
                            Console.WriteLine();
                            Console.WriteLine($"Your Total Amount Is {test.Wallet}");
                            Console.WriteLine("Please Select An Item, Or Press \"K\" to Return.");
                            string itemSelect = Console.ReadLine().ToUpper();
                            test.Purchase(itemSelect);
                        }
                        else
                        {
                            test.EndTransaction();
                            Console.WriteLine($"Dispensing {test.dollarValue} Dollars");
                            Console.WriteLine($"Dispensing {test.quarterValue} Quarters");
                            Console.WriteLine($"Dispensing {test.dimeValue} Dimes");
                            Console.WriteLine($"Dispensing {test.nickelValue} Nickels");
                            Console.WriteLine();
                        }
                    }
                }
                break;

                case "3":
                    main = false;
                    break;

                case "4":
                    test.SalesReport();
                    main = false;
                    break;

                default:
                    throw new MenuSelectError();
                }
            }
            Console.WriteLine("Thank you for Using the Vendo-Matic 600 (By Umbrella Corp.) GoodBye");
            Console.ReadKey();
        }