/**
 * Bank Account info:
 * - first name
 * - last name
 * - type of accounts (chequing, savings)
 * - account number
 * - balance
 * - overdraft? address, etc? we abstract the real world and simplify!  
 * 
 * Actions:
 * - withdraw
 * - deposit
 * - get balance
 * - transfer? interest? again we simplify and ignore these.
 */
public class BankAccount {
  
  /** The first name of the bank account owner. */
  private String firstName;
  
  /** The last name of the bank account owner. */
  private String lastName;
  
  /** The type of the bank account. */
  private boolean isChequing;
  
  /** The account balance. */
  private double balance;
    
  /** The account number. */
  private int number;
  
  /** The name of the bank. */
  private String bankName;
  
  /** The total number of accounts ever created. */
  private static int totalNumAccounts;
  
  /** A constant for the deposit fee. */
  public static final double DEPOSIT_FEE = 5.0;
  
  /** A constant for the bank name.*/
  public static final String BANK_NAME = "TD";

  /**
   * Create a new bank account with first name f,
   * last name l, account type t, balance b, and
   * account number n.
   */
  public BankAccount(String f, String l, double b, boolean t, int n) {
    this.firstName = f;
    this.lastName = l;
    this.balance = b;
    this.isChequing = t;
    this.number = n;
    this.bankName = BANK_NAME;
    totalNumAccounts++;
  }
  
  /**
   * Create a new chequing bank account with first name f,
   * last name l, and account number n. default balance is $20
   */ 
  public BankAccount(String f, String l, int n) {
    this(f, l, 20.0, true, n);
  }

  /**
   * Get the bank account balance.
   */
  public double getBalance() {
    return this.balance;
  }
  
  /** 
   * Withdraw amount d from the bank account.
   */
  public void withdraw(double d) {
    this.balance = this.balance - d;
  }
  
  /**
   * Deposit amount a into the bank account.
   */
  public void deposit(double d) {
    this.balance += d;
    this.balance -= DEPOSIT_FEE;
  }
  
  /**
   * Returns the total number of bank accounts ever created.
   * - this is a static method!
   * - cannot access non-static data inside this method.
   */
  public static int getTotalNumAccounts() {
    return totalNumAccounts;
  }

  /** 
   * compares this bank account with another one.
   * Two bank accounts considered the same if they
   * have the same account number.
   */
  public boolean isEqual(BankAccount ba2){
    return this.number == ba2.number;
  }

}
