Java Reference
In-Depth Information
public String getName() {
return name;
}
 
private void setName(String name) {
this.name = name;
}
 
public BigDecimal getAmount() {
return amount;
}
 
private void setAmount(BigDecimal amount) {
this.amount = amount;
}
 
@Override
public String toString() {
return "CheckingAccount " + this.getName()
+ ": Balance = " + this.getAmount();
}
 
}
8.
Create an AccountManager class to test your interface‐based application. You can reuse parts of
the AccountManager class from the earlier exercise. It may look different from the one here, but
should function in mostly the same way:
public class AccountManager {
 
public static void main(String[] args) {
Accountable mySavings, myChecking;
try {
mySavings = new SavingsAccount("Save001", "10.00");
System.out.println(mySavings);
 
mySavings.withdraw("5.00");
System.out.println(mySavings);
 
myChecking = new CheckingAccount("Check002", "10.00");
System.out.println(myChecking);
 
myChecking = new CheckingAccount("Check002", "101.00");
System.out.println(myChecking);
 
myChecking.withdraw("5.00");
System.out.println(myChecking);
 
myChecking.deposit("500.00");
System.out.println(myChecking);
 
myChecking.withdraw("5.00");
System.out.println(myChecking);
} catch (IllegalAccount a) {
Search WWH ::




Custom Search