Advertisement
KBonnicksen

Untitled

Mar 12th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. public void transfer(BankAccount acct, double amount){
  2.  
  3.     //Does nothing if transfer amount is 0 or less
  4.     if(amount >= 0){
  5.         if(this.balance > 5){
  6.             this.transactions++;
  7.             acct.transactions++;
  8.  
  9.             //Transfers their remaining balance if there are insufficient funds
  10.             if((this.balance - 5) <= amount){
  11.                 acct.balance += this.balance - 5;
  12.                 this.balance = 0;
  13.             }
  14.  
  15.             //Executes a normal transaction if there are enough funds
  16.             else{
  17.                 this.balance -= (5.00 + amount);
  18.                 acct.balance += amount;
  19.             }
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement