コード例 #1
0
        /// <summary>
        /// Opens the Purchase sub-menu
        /// </summary>
        /// <returns></returns>
        private MenuOptionResult PurchaseMenu()
        {
            PurchaseMenu purchaseMenu = new PurchaseMenu(this.machine);

            purchaseMenu.Show();
            return(MenuOptionResult.DoNotWaitAfterMenuSelection);
        }
コード例 #2
0
ファイル: MainMenu.cs プロジェクト: ADorscheid/Bootcamp
        private MenuOptionResult Purchase()
        {
            PurchaseMenu purchaseMenu = new PurchaseMenu(this.VendingMachine);

            purchaseMenu.Show();
            return(MenuOptionResult.WaitAfterMenuSelection);
        }
コード例 #3
0
        public MenuOptionResult BeginPurchase()
        {
            PurchaseMenu menu = new PurchaseMenu(machine);

            menu.Show();
            return(MenuOptionResult.DoNotWaitAfterMenuSelection);
        }
コード例 #4
0
        // Provides change amount to user and dispenses it
        public MenuOptionResult ExitStatement()
        {
            PurchaseMenu purchaseMenu = new PurchaseMenu();

            purchaseMenu.ourVendingMachine = this.ourVendingMachine;
            purchaseMenu.Show();
            Console.WriteLine($"Here's your Change Amount: ${ourVendingMachine.Balance}");

            ourVendingMachine.AuditLogGiveChangeMethod("GIVE CHANGE:", ourVendingMachine.Balance, 0);

            decimal twentyDollarBill = 20M;
            decimal tenDollarBill    = 10M;
            decimal fiveDollarBill   = 5M;
            decimal oneDollarBill    = 1M;
            decimal quarter          = 0.25M;
            decimal dime             = 0.10M;
            decimal nickel           = 0.05M;
            //decimal userChangeBalance = Balance;
            int twentyDollarCount   = 0;
            int tenDollarBillCount  = 0;
            int fiveDollarBillCount = 0;
            int oneDollarBillCount  = 0;
            int quarterCount        = 0;
            int dimeCount           = 0;
            int nickelCount         = 0;

            for (decimal i = 0M; i >= 0; i++)
            {
                if (ourVendingMachine.Balance >= twentyDollarBill)
                {
                    ourVendingMachine.Balance = ourVendingMachine.Balance - twentyDollarBill;
                    twentyDollarCount++;
                    //Console.WriteLine($"Twenty Dollar Bills: {twentyDollarCount}");
                }
                else if (ourVendingMachine.Balance >= tenDollarBill && ourVendingMachine.Balance < twentyDollarBill)
                {
                    ourVendingMachine.Balance = ourVendingMachine.Balance - tenDollarBill;
                    tenDollarBillCount++;
                }
                else if (ourVendingMachine.Balance >= fiveDollarBill && ourVendingMachine.Balance < tenDollarBill)
                {
                    ourVendingMachine.Balance = ourVendingMachine.Balance - fiveDollarBill;
                    fiveDollarBillCount++;
                    //Console.WriteLine(fiveDollarBillCount);
                }
                else if (ourVendingMachine.Balance >= oneDollarBill && ourVendingMachine.Balance < fiveDollarBill)
                {
                    ourVendingMachine.Balance = ourVendingMachine.Balance - oneDollarBill;
                    oneDollarBillCount++;
                }
                else if (ourVendingMachine.Balance >= quarter && ourVendingMachine.Balance < oneDollarBill)
                {
                    ourVendingMachine.Balance = ourVendingMachine.Balance - quarter;
                    quarterCount++;
                    //Console.WriteLine(quarterCount);
                }
                else if (ourVendingMachine.Balance >= dime && ourVendingMachine.Balance < quarter)
                {
                    ourVendingMachine.Balance = ourVendingMachine.Balance - dime;
                    dimeCount++;
                    //Console.WriteLine(dimeCount);
                }
                else if (ourVendingMachine.Balance >= nickel && ourVendingMachine.Balance < dime)
                {
                    ourVendingMachine.Balance = ourVendingMachine.Balance - nickel;
                    nickelCount++;
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine($"Twenty Dollar Bills: {twentyDollarCount}");
            Console.WriteLine($"Ten Dollar Bills: {tenDollarBillCount}");
            Console.WriteLine($"Five Dollar Bills: {fiveDollarBillCount}");
            Console.WriteLine($"One Dollar Bills: {oneDollarBillCount}");
            Console.WriteLine($"Quarters: {quarterCount}");
            Console.WriteLine($"Dimes: {dimeCount}");
            Console.WriteLine($"Nickels: {nickelCount}");

            return(MenuOptionResult.WaitAfterMenuSelection);
        }
コード例 #5
0
        private MenuOptionResult Purchase()
        {
            purchaseMenu.Show();

            return(MenuOptionResult.WaitAfterMenuSelection);
        }