Service.AccountService.Withdraw C# (CSharp) Method

Withdraw() public method

public Withdraw ( IAccount account, double amount ) : void
account IAccount
amount double
return void
        public void Withdraw(IAccount account, double amount)
        {
            if (account is CheckingAccount)
            {
                var checkingAccount = (CheckingAccount) account;

                if (checkingAccount.GetAmount() + checkingAccount.GetCreditLimit() < amount)
                {
                    throw new InnsufficientFundsException();
                }
            }
            else
            {
                if (account.GetAmount() < amount)
                {
                    throw new InnsufficientFundsException();
                }
            }

            double oldAmount = account.GetAmount();
            account.SetAmount(oldAmount - amount);
        }
AccountService