Ejemplo n.º 1
0
        //public VendingMachine Vendo_Matic_800 { get; set; }
        /// <summary>
        /// The override of ExecuteSelection handles whatever selection was made by the user.
        /// This is where any business logic is executed.
        /// </summary>
        /// <param name="choice">"Key" of the user's menu selection</param>
        /// <returns></returns>
        protected override bool ExecuteSelection(string choice)
        {
            switch (choice)
            {
            case "1":
                ItemsMenu itemsMenu = new ItemsMenu(Vendo_Matic_800);
                itemsMenu.Run();
                return(true);

            case "2":
                PurchaseMenu purchaseMenu = new PurchaseMenu(Vendo_Matic_800);
                purchaseMenu.Run();
                return(true);

            case "E":
                Console.Clear();
                Console.WriteLine($"*****  Thank you for using the Vendo-Matic-800!!!  *****");
                Console.WriteLine();
                Vendo_Matic_800.quarters = 0;
                Vendo_Matic_800.dimes    = 0;
                Vendo_Matic_800.nickels  = 0;
                Vendo_Matic_800.EndVending();
                string changeString = $"Please take your change: {Vendo_Matic_800.quarters} Quarters, {Vendo_Matic_800.dimes} Dimes, {Vendo_Matic_800.nickels} Nickels.";
                Console.WriteLine(new string('=', changeString.Length));
                Console.WriteLine(changeString);
                Console.WriteLine(new string('=', changeString.Length));
                Console.WriteLine();
                Console.WriteLine("Press [ENTER] to continue!");
                Console.ReadLine();
                Environment.Exit(0);
                return(false);

            case "4":
                Vendo_Matic_800.GenerateSalesReport();
                return(true);
            }
            return(true);
        }
Ejemplo n.º 2
0
        //public VendingMachine Vendo_Matic_800 { get; set; }


        /// <summary>
        /// The override of ExecuteSelection handles whatever selection was made by the user.
        /// This is where any business logic is executed.
        /// </summary>
        /// <param name="choice">"Key" of the user's menu selection</param>
        /// <returns></returns>
        protected override bool ExecuteSelection(string choice)
        {
            switch (choice)
            {
            case "1":
                Console.Clear();
                string titleDisplay = $"        ************  Your current balance is {Vendo_Matic_800.Balance:C}  ************        ";
                Console.WriteLine();
                Console.WriteLine(titleDisplay);
                Console.WriteLine(new string('=', titleDisplay.Length));
                Console.WriteLine();
                decimal moneyFeed = GetDecimal("Enter whole dollar amount to deposit or press [ENTER] to return to menu: ");
                Vendo_Matic_800.Deposit(moneyFeed);

                if (moneyFeed > 10000000)
                {
                    Console.Clear();
                    string tooBigWarning = "!!!!  Deposit Amount Exceeds Inventory Value  !!!!";
                    Console.WriteLine(new string('=', tooBigWarning.Length));
                    Console.WriteLine(tooBigWarning);
                    Console.WriteLine(new string('=', tooBigWarning.Length));
                    Console.WriteLine();
                    Console.WriteLine("Press [ENTER] to return to the menu");
                    Console.ReadLine();
                }
                else if (moneyFeed <= 0)
                {
                    Console.WriteLine("Please enter a positive whole dollar amount, Press Enter to Continue");
                    Console.ReadLine();
                }

                Console.Clear();
                string titleDisplayNewBalance = $"        ************  Your current balance is {Vendo_Matic_800.Balance:C}  ************        ";
                Console.WriteLine();
                Console.WriteLine(titleDisplayNewBalance);
                Console.WriteLine(new string('=', titleDisplayNewBalance.Length));
                Console.WriteLine();
                Console.WriteLine("Press [ENTER] to return to the Purchase Menu");
                Console.ReadLine();
                return(true);

            case "2":
                ItemSelection itemSelection = new ItemSelection(Vendo_Matic_800);
                itemSelection.Run();
                return(true);

            case "F":
                Console.Clear();
                Console.WriteLine($"*****  Thank you for using the Vendo-Matic-800!!!  *****");
                Console.WriteLine();
                Vendo_Matic_800.quarters = 0;
                Vendo_Matic_800.dimes    = 0;
                Vendo_Matic_800.nickels  = 0;
                Vendo_Matic_800.EndVending();
                string changeString = $"Please take your change: {Vendo_Matic_800.quarters} Quarters, {Vendo_Matic_800.dimes} Dimes, {Vendo_Matic_800.nickels} Nickels.";
                Console.WriteLine(new string('=', changeString.Length));
                Console.WriteLine(changeString);
                Console.WriteLine(new string('=', changeString.Length));
                Console.WriteLine();
                Console.WriteLine("Press [ENTER] to continue!");
                Console.ReadLine();
                MainMenu mainMenu = new MainMenu(Vendo_Matic_800);
                mainMenu.Run();
                return(true);

            case "M":
                MainMenu mainMenu2 = new MainMenu(Vendo_Matic_800);
                mainMenu2.Run();
                return(true);

                //return false;
            }
            return(true);
        }