Beispiel #1
0
        /// <summary>
        /// Run an infinite loop until "break."
        /// </summary>
        public void Run()
        {
            while (true)
            {
                Console.WriteLine("Welcome to Vendo-Matic 500!");
                Console.WriteLine("Please make a choice.");
                Console.WriteLine("1. Display Vending Machine items.");
                Console.WriteLine("2. Purchase.");
                Console.WriteLine("3. Quit.");
                Console.WriteLine("> Please Pick One: ");
                string choice = Console.ReadLine();

                if (choice == "1")
                {
                    DisplayMenu displayMenu = new DisplayMenu();
                    displayMenu.Run(vm.inventory);
                }
                else if (choice == "2")
                {
                    PurchaseMenu purchaseMenu = new PurchaseMenu();
                    purchaseMenu.Run(vm);
                }
                else if (choice == "3")
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Invalid option.");
                    Console.ReadLine();
                }
            }
        }
        /// <summary>
        /// Runs main menu for our vending machine. Inputs are location of files for program.
        /// </summary>
        /// <param name="inventoryList"></param>
        /// <param name="logs"></param>
        /// <param name="salesReport"></param>
        public static void MainMenu(VendingMachine vendingMachine)
        {
            bool isExit = false;

            while (!isExit)
            {
                Console.Clear();
                Console.WriteLine("Welcome to Vendo-Matic 600!");
                Console.WriteLine("by Umbrella Corp.");
                Console.WriteLine();

                Console.WriteLine("Menu options:");
                Console.WriteLine($"{DISPLAY_KEY.ToString().Substring(1)}. Display items.");
                Console.WriteLine($"{PURCHASE_KEY.ToString().Substring(1)}. Purchase items.");
                Console.WriteLine($"{EXIT_KEY.ToString().Substring(1)}. Exit.");

                var menuSelection = Console.ReadKey().Key;

                if (menuSelection == DISPLAY_KEY)
                {
                    DisplayMenu.DisplayItemsMenu(vendingMachine);
                }
                else if (menuSelection == PURCHASE_KEY)
                {
                    PurchaseMenu.PurchaseItemsMenu(vendingMachine);
                }
                else if (menuSelection == EXIT_KEY)
                {
                    isExit = true;
                }
                else if (menuSelection == REPORT_KEY)
                {
                    vendingMachine.MakeSalesReport();

                    DisplayMessage("A new Sales Report has been generated.");
                }
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            DisplayMenu displayMenu = new DisplayMenu();

            displayMenu.Display();
        }