.\banking\GUIAccountsDriver.java
import java.io.*;
import java.applet.*;
import java.awt.*;
import account.*;
public class GUIAccountsDriver extends Applet {
TextArea stdOut,stdErr;
public void init() {
{
stdOut = new TextArea(20,80);
stdErr = new TextArea(5,80);
// Checking Account
CheckingAccount mickey = new
CheckingAccount("Mickey Mouse", 100.0, 25.0);
stdOut.append("Checking Account" + '\n');
stdOut.append("info: " + mickey + '\n');
stdOut.append("withdrawing 30 dollars ..." + '\n');
try {
// this one should be fine
mickey.withdraw(30.0);
} catch (IllegalArgumentException iae) {
stdErr.append(iae.toString() + '\n');
}
stdOut.append("balance: " + mickey.getFormattedBalance() + '\n');
stdOut.append("withdrawing 60 dollars ..." + '\n');
try {
// this one will overdraw, throwing an exception
mickey.withdraw(60.0);
} catch (IllegalArgumentException iae) {
stdErr.append(iae.toString() + '\n');
}
stdOut.append("balance: " + mickey.getFormattedBalance() + '\n');
}
stdOut.append('\n' + "Savings Account" + '\n');
{
// Savings Account
SavingsAccount minnie = new
SavingsAccount("Minnie Mouse", 400.0, 0.05);
stdOut.append("info: " + minnie + '\n');
stdOut.append("withdrawing 100 dollars ..." + '\n');
try {
// this one should be fine
minnie.withdraw(100.0);
} catch (IllegalArgumentException iae) {
stdErr.append(iae.toString() + '\n');
}
stdOut.append("balance: " + minnie.getFormattedBalance() + '\n');
stdOut.append("adding daily interest ..." + '\n');
minnie.addDailyInterest();
stdOut.append("balance: " + minnie.getFormattedBalance() + '\n');
stdOut.append("interest rate: " +
minnie.getFormattedInterestRate() + '\n');
stdOut.append("changing interest rate to " + -7 + "%" + '\n');
try {
minnie.setInterestRate(-0.07);
} catch (IllegalArgumentException iae) {
stdErr.append(iae.toString() + '\n');
}
stdOut.append("interest rate: " +
minnie.getFormattedInterestRate() + '\n');
}
stdOut.append('\n' + "Bond Account" + '\n');
{
// Bond Account
BondAccount goofy = new BondAccount("Goofy Dog", 600.0, 0.07);
stdOut.append("info: " + goofy);
stdOut.append("depositing 200 dollars ..." + '\n');
goofy.deposit(200.0);
stdOut.append("adding daily interest ..." + '\n');
goofy.addDailyInterest();
stdOut.append("balance: " + goofy.getFormattedBalance() + '\n');
stdOut.append("Maximum number of withdrawals: " +
goofy.maxWd() + '\n');
stdOut.append("withdrawing 200 dollars ..." + '\n');
try {
// this one should be fine
goofy.withdraw(100.0);
} catch (IllegalArgumentException iae) {
stdErr.append(iae.toString() + '\n');
}
stdOut.append("balance: " + goofy.getFormattedBalance() + '\n');
stdOut.append("withdrawing 20 dollars ..." + '\n');
try {
// this one should be fine
goofy.withdraw(20.0);
} catch (IllegalArgumentException iae) {
stdErr.append(iae.toString() + '\n');
}
stdOut.append("balance: " + goofy.getFormattedBalance() + '\n');
stdOut.append("withdrawing 50 dollars ..." + '\n');
try {
// this one is beyone maximum number of withdrawals
goofy.withdraw(100.0);
} catch (IllegalArgumentException iae) {
stdErr.append(iae.toString() + '\n');
}
stdOut.append("balance: " + goofy.getFormattedBalance() + '\n');
}
add(stdOut);
add(stdErr);
}
}