public void WithDraw(int accNo, decimal amount, string comment) { if (amount <= 0) { throw new ArgumentException( "amount to withdraw must be greater than 0"); } Account acc = Impl.GetAccountByAccountNumber(accNo); if (acc is null) { throw new ArgumentException( "the specified account does not exist"); } decimal serviceFee = 0; if (TMImpl.CountChargedTransactions() >= TransactionManager.NFreeTransactions) { serviceFee = TransactionManager.ServiceFee['W']; } if (acc.Balance - amount - serviceFee < MinBalance[acc.AccountType]) { throw new BalanceTooLowException( "after withdrawal (including service fee), remaining balance " + "would be lower than the minimum balance allowed."); } Impl.WithDraw(accNo, amount, comment, serviceFee); }
public void Transfer(int srcNo, int destNo, decimal amount, string comment) { if (amount <= 0) { throw new ArgumentException( "amount to transfer must be greater than 0"); } Account srcAcc = Impl.GetAccountByAccountNumber(srcNo); if (srcAcc is null) { throw new ArgumentException( "account to transfer from does not exist"); } Account destAcc = Impl.GetAccountByAccountNumber(destNo); if (destAcc is null) { throw new ArgumentException( "account to transfer to does not exist"); } decimal serviceFee = 0; if (TMImpl.CountChargedTransactions() >= TransactionManager.NFreeTransactions) { serviceFee = TransactionManager.ServiceFee['T']; } if (srcAcc.Balance - amount - serviceFee < MinBalance[srcAcc.AccountType]) { throw new BalanceTooLowException( "after transfer (including service fee), remaining balance " + "would be lower than the minimum balance allowed."); } Impl.Transfer(srcNo, destNo, amount, comment, serviceFee); }