示例#1
0
        public void TestCashAvailable()
        {
            decimal       input         = 499 * 20; // Initial Count = 500
            CashDispenser cashDispenser = new CashDispenser();

            Assert.IsTrue(cashDispenser.IsSufficiantCashAvailable(input));
        }
示例#2
0
        public override void Execute(int accountNumber, Screen atmScreen)
        {
            bool    isCashDispensed = false;
            decimal availableBalance;

            BankDatabase bankDatabase = BankDatabase;

            do
            {
                _amount = DisplayMenuOfAmounts(atmScreen);

                if (_amount != CANCELED)
                {
                    availableBalance = bankDatabase.GetAvailableBalance(accountNumber);
                    if (_amount <= availableBalance)
                    {
                        if (_cashDispenser.IsSufficiantCashAvailable(_amount))
                        {
                            bankDatabase.Debit(accountNumber, _amount);
                            _cashDispenser.DispenseCash(_amount);
                            isCashDispensed = true;

                            atmScreen.DisplayMessageLine("\nYour cash has been dispensed. Please take your cash now.");
                        }
                        else
                        {
                            atmScreen.DisplayMessageLine("\nInsufficient cash available in the ATM.\n\nPlease choose a smaller amount.");
                        }
                    }
                    else
                    {
                        atmScreen.DisplayMessage("\nInsufficient funds in your account.\n\nPlease choose a smaller amount.");
                    }
                    Sleep(3000);
                }
                else
                {
                    atmScreen.DisplayMessageLine("\nCancelling transaction...");
                    Sleep(3000);
                    return;
                }
            } while (!isCashDispensed);
        }