public static void main(String[] args) {
   // init object
   Account account1 = new Account(50.00);
   Account account2 = new Account(-7.53);
   // print objects balance
   System.out.printf("account1 balance: $%.2f\n", account1.getBalance());
   System.out.printf("account2 balance: $%.2f\n", account2.getBalance());
   // create scanner to read user input
   Scanner input = new Scanner(System.in);
   double depositAmount; // deposite amount read from user
   System.out.print("Enter deposit amount for account 1: ");
   depositAmount = input.nextDouble();
   System.out.printf("\nadding %.2f to account1 balance\n\n", depositAmount);
   account1.credit(depositAmount);
   // display message
   System.out.printf("account1 balance $%.2f\n", account1.getBalance());
   System.out.printf("account2 balance $%.2f\n", account2.getBalance());
   // prompt
   System.out.print("Enter deposit amount for account2: ");
   depositAmount = input.nextDouble();
   System.out.printf("\nadding %.2f to account2 balance\n\n", depositAmount);
   account2.credit(depositAmount);
   // display balance
   System.out.printf("account1 balance $%.2f\n", account1.getBalance());
   System.out.printf("account2 balance $%.2f\n", account2.getBalance());
 }
 /**
  * @param amount
  * @param source
  * @param target
  */
 public static void transfer(double amount, Account source, Account target) {
   if (source.getBalance() < amount) {
     System.out.println(source.getBalance() + "  " + amount);
     throw new IllegalStateException();
   }
   source.debit(amount);
   target.credit(amount);
 }
 public BankingTransaction transfer(String fromAccountId, String toAccountId, double amount)
     throws MoneyTransferException {
   Account fromAccount = accountRepository.findAccount(fromAccountId);
   Account toAccount = accountRepository.findAccount(toAccountId);
   fromAccount.debit(amount);
   toAccount.credit(amount);
   return bankingTransactionRepository.createTransferTransaction(fromAccount, toAccount, amount);
 }
  /**
   * A transfer method which transfers the amount of money from the account with the senderId to the
   * account of beneficiaryId.
   *
   * @param senderId
   * @param beneficiaryId
   * @param amount
   */
  public void transfer(String senderId, String beneficiaryId, long amount) {
    Account sender = this.accountManager.findAccountForUser(senderId);
    Account beneficiary = this.accountManager.findAccountForUser(beneficiaryId);

    sender.debit(amount);
    beneficiary.credit(amount);
    this.accountManager.updateAccount(sender);
    this.accountManager.updateAccount(beneficiary);
  }