UNB/ CS/ David Bremner/ teaching/ old/ cs1083/ java/ TimeDepositAccount.java
import java.math.BigDecimal;
public class TimeDepositAccount extends SavingsAccount
{
    private int periodsToMaturity;
    private static BigDecimal EARLY_WITHDRAWAL_PENALTY = new BigDecimal(20);

    public TimeDepositAccount(int permille, int maturity)
    {
        super(permille,0,0);
        periodsToMaturity = maturity;
    }

    public final void addInterest() {
        periodsToMaturity--;
        super.addInterest();
    }

    public final void withdraw(BigDecimal amount)
    {
        if (periodsToMaturity > 0)
            super.withdraw(EARLY_WITHDRAWAL_PENALTY);
        super.withdraw(amount);
    }

}