import java.util.*; import java.awt.*; // // CD account class // class CDAccount extends MonthlyAccount { static final double withdrawFee=250.0f; // the valability period of the CD account int CDperiod; CDAccount(String accountname, double deposit, int period, double accountinterest, TextArea out) throws NoNameException { super(accountname,accountinterest,out); // make CD-specific initializations balance=deposit; CDperiod=period; } void Deposit(double amount) throws NegativeAmountException,InvalidDepositException { throw new InvalidDepositException(new String(Name())); } void Withdraw(double amount) throws NegativeAmountException, CDNegativeBalanceException { if(CDperiod>0) { // fee is imposed before the CD period expires balance-=withdrawFee; } if(amount<0) throw new NegativeAmountException(new String(Name())); if(balance-amount<0) throw new CDNegativeBalanceException(new String(Name())); // update balance balance-=amount; } void ComputeInterest() { super.ComputeInterest(); // update the maturity period of the CD account if(date==1 && CDperiod>0) CDperiod=CDperiod-1; } void Update() { date=date%30+1; ComputeInterest(); } public void Output() { Double doubleNo=new Double(0); Integer intNo=new Integer(0); output.appendText("CD Account: "+Name()+"\nbalance: "+doubleNo.toString(Balance()) +"\nmaturity period: "+intNo.toString(CDperiod) +" month(s)\nmonthly interest: "+doubleNo.toString(interest)+"%\n"); } }