public class CheckingAccount extends BankAccount
{
  private int transCount;
  private static final int NUM_FREE = 3;
  private static final double TRANS_FEE = 2.0;

  public CheckingAccount()
  {
    this.transCount = 0;
  }

  public void deposit(double amount)
  {
    super.deposit(amount);
    this.transCount++;
  }

  public void withdraw(double amount)
  {
    super.withdraw(amount);
    this.transCount++;
  }

  public void deductFees()
  {
    if (this.transCount > NUM_FREE) {
      double fees =
        TRANS_FEE*(this.transCount - NUM_FREE);
      super.withdraw(fees);
    }
    this.transCount = 0;
  }
}
