BankAccount.java.html

  1  /**
  2     A bank account has a balance and a mechanism for applying interest or fees at 
  3     the end of the month.
  4  */
  5  public class BankAccount
  6  {
  7     private double balance;
  8  
  9     /**
 10        Constructs a bank account with zero balance.
 11     */
 12     public BankAccount()
 13     {
 14        balance = 0;
 15     }
 16  
 17     /**
 18        Makes a deposit into this account.
 19        @param amount the amount of the deposit
 20     */
 21     public void deposit(double amount)
 22     {
 23        balance = balance + amount;
 24     }
 25     
 26     /**
 27        Makes a withdrawal from this account, or charges a penalty if
 28        sufficient funds are not available.
 29        @param amount the amount of the withdrawal
 30     */
 31     public void withdraw(double amount)
 32     {
 33        balance = balance - amount;
 34     }
 35     
 36     /**
 37        Carries out the end of month processing that is appropriate
 38        for this account.
 39     */
 40     public void monthEnd() 
 41     {
 42     }
 43     
 44     /**
 45        Gets the current balance of this bank account.
 46        @return the current balance
 47     */
 48     public double getBalance()
 49     {
 50        return balance;
 51     }
 52  }