daniel_lawson9999

Daniel Lawson bankAccount

Sep 26th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. /**
  2.  * Created by danie on 9/25/2016.
  3.  */
  4. public class bankAccount {
  5.     private String name;
  6.     private double balance;
  7.     private double transsactionFee;
  8.  
  9.     public void deposit(double amount){
  10.         balance +=amount;
  11.     }
  12.     public void withdraw(double amount){
  13.         if(balance - amount - transsactionFee >=0)balance -= (amount + transsactionFee);
  14.     }
  15.     public String toString(){
  16.  
  17.         return (name + ", $" +balance);
  18.     }
  19.     public void transfer(bankAccount other, double amount){
  20.         if(amount >=5){
  21.             balance -= 5;
  22.             if(balance>=amount){
  23.                 balance-=amount;
  24.                 other.deposit(amount);
  25.             }
  26.             else{
  27.                 other.deposit(balance);
  28.                 balance = 0;
  29.             }
  30.         }
  31.     }
  32. }
Add Comment
Please, Sign In to add comment