public void doTransfer(String fromNumber, String toNumber, double amount) throws BankTransactionException { AbstractAccount fromAccount; fromAccount = associateAccount(fromNumber); AbstractAccount toAccount; toAccount = associateAccount(toNumber); ; try { fromAccount.debit(amount); toAccount.credit(amount); repository.persist(); } catch (InsufficientFundsException | NegativeAmountException | IOException e) { throw new BankTransactionException(e); } try { log.userOperationTransf(fromNumber, toNumber, amount); } catch (IOException e) { e.printStackTrace(); } }
public void doDebit(String number, double amount) throws BankTransactionException { account = associateAccount(number); try { account.debit(amount); repository.persist(); } catch (NegativeAmountException | InsufficientFundsException | IOException e) { throw new BankTransactionException(e); } try { log.userOperationCredDeb("Debit", number, amount); } catch (IOException e) { e.printStackTrace(); } }
public void doCredit(String number, double amount) throws BankTransactionException { account = associateAccount(number); try { account.credit(amount); repository.persist(); } catch (NegativeAmountException | FileNotFoundException nae) { throw new BankTransactionException(nae); } try { log.userOperationCredDeb("Credit", number, amount); } catch (IOException e) { e.printStackTrace(); } }
public double getBalance(String number) throws BankTransactionException { account = associateAccount(number); return account.getBalance(); }