1  /**
  2     A bank account has a balance that can be changed by 
  3     deposits and withdrawals.
  4  */
  5  public class BankAccount implements Measurable
  6  {  
  7     private double balance;
  8  
  9     /**
 10        Constructs a bank account with a zero balance.
 11     */
 12     public BankAccount()
 13     {   
 14        balance = 0;
 15     }
 16  
 17     /**
 18        Constructs a bank account with a given balance.
 19        @param initialBalance the initial balance
 20     */
 21     public BankAccount(double initialBalance)
 22     {   
 23        balance = initialBalance;
 24     }
 25  
 26     /**
 27        Deposits money into the bank account.
 28        @param amount the amount to deposit
 29     */
 30     public void deposit(double amount)
 31     {  
 32        double newBalance = balance + amount;
 33        balance = newBalance;
 34     }
 35  
 36     /**
 37        Withdraws money from the bank account.
 38        @param amount the amount to withdraw
 39     */
 40     public void withdraw(double amount)
 41     {   
 42        double newBalance = balance - amount;
 43        balance = newBalance;
 44     }
 45  
 46     /**
 47        Gets the current balance of the bank account.
 48        @return the current balance
 49     */
 50     public double getBalance()
 51     {   
 52        return balance;
 53     }
 54  
 55     public double getMeasure()
 56     {
 57        return balance;
 58     }
 59  }