Exemplo n.º 1
0
        public void DisplayPurchaseMenu()
        {
            string input;
            bool   keepGoing = true;

            while (keepGoing)
            {
                Console.Clear();
                DisplayLogo();

                Console.WriteLine("1) Feed Money");     // allow user to input whole dollar amount repeatedly
                Console.WriteLine("2) Select Product"); //Display items & allow user to select using sortId
                Console.WriteLine("3) Finish Transaction");
                Console.WriteLine("\n");

                Console.WriteLine($"Current Money Provided: {VM.Balance:c}");
                Console.Write("Please Enter Selection: ");
                input = Console.ReadLine();

                switch (input)
                {
                case "1":     //Feedmoney
                    GetUsersPayment();
                    continue;

                case "2":     //Select product
                    Dictionary <string, VendingMachineItem> items = VM.Inventory;
                    DisplayItems(items);
                    SelectItem(items);
                    break;

                case "3":     //Finish Transaction
                    MoneyChanger change = new MoneyChanger(VM.Balance);
                    VM.MakeChange();
                    PrintChange(change);
                    keepGoing = false;
                    break;

                default:
                    Console.WriteLine("Invalid Menu Option. Please Try Again.");
                    continue;
                }

                Console.ReadLine();
            }

            MainMenu m = new MainMenu(VM);

            m.DisplayMainMenu();
        }
Exemplo n.º 2
0
 public void PrintChange(MoneyChanger change)
 {
     Console.WriteLine($"Here is your change: {change.Quarters} Quarters, {change.Dimes} Dimes, {change.Nickels} Nickels, and {change.Pennies} Pennies");
 }