Beispiel #1
0
 public ATMResponse GetAccountBalance(CustomerAccount account, Int32 pinNumber, out decimal accountBalance)
 {
     accountBalance = 0;
     if (IsPinValid(account, pinNumber))
     {
         accountBalance = account.GetBalance();
         return ATMResponse.SUCCESS;
     }
     return ATMResponse.ACCOUNT_ERR;
 }
Beispiel #2
0
        public ATMResponse WithdrawFunds(decimal withdrawalAmount, CustomerAccount account, Int32 pinNumber, out decimal accountBalance)
        {
            accountBalance = 0;
            if (!IsPinValid(account, pinNumber))
                return ATMResponse.ACCOUNT_ERR;

            // check if the cashmachine has enough cash for the withdrawal request
            if (withdrawalAmount > _machineBalance)
                return ATMResponse.ATM_ERR;

            if (withdrawalAmount <= account.GetWithdrawalBalance())
            {
                account.WithdrawFunds(withdrawalAmount);
                accountBalance = account.GetBalance();
            }
            else
            {
                return ATMResponse.FUNDS_ERR;
            }
            return ATMResponse.SUCCESS;
        }