Wednesday, November 10, 2010

Chapter 8 test

public void withdraw (double withdrawAmount)
{
if (withdrawAmount <= getBalance())
{
setBalance(getBalance()-withdrawAmount);
}

if (withdrawAmount > getBalance() && withdrawAmount - getBalance() <= limit)
{
setBalance(getBalance()-withdrawAmount);
fee = fee % 10;
}

if (withdrawAmount > getBalance() && withdrawAmount - getBalance() > limit)
{
System.out.println("Please specify an amount within the limit. The limit is: "+limit);
}
}//end withdraw



a. Deposit method to transfer
b. BankAccount is super class of class GoldBankAccount
GoldBankAccount inherits from class BankAccount. You use superclass constructor when you create class GoldBankAccount.

c. When you define the ArrayList, you define to be of type Object which call hold all kinds of classes.
e. Because ArrayLists cannot hold primitive types, we have wrapper classes such as integer.

No comments:

Post a Comment