Answer:
class CheckingAccount
{
private String accountNumber;
private String accountHolder;
private int balance;
private int useCount = 0;
public CheckingAccount( String accNumber, String holder, int start ) { . . . . }
private void incrementUse() { . . . . }
public int getBalance() { . . . . }
public void processDeposit( int amount ) { . . . . }
public void processCheck( int amount ) { . . . . }
}
toString() Method
It would be nice to have a toString() method in this class that
shows the use count as well as the other data.
There is already a toString() method.
All classes automatically have such a method.
(This is done by inheritance, and subject of a upcoming chapter.)
But the automatically supplied method
may not do what you want.
If you write your own toString() method
it will replace the automatically supplied one.
The method must look like this:
public String toString()
{
}
The method must be declared to be public
class CheckingAccount
{
private String accountNumber;
private String accountHolder;
private int balance;
private int useCount = 0;
. . . .
public String toString()
{
return "Account: " + accountNumber + "/tName: " + accountHolder +
"/tBalance: " + balance + "/tUse Count: " + ;
}
}
QUESTION 12:
Modify the method so that it also prints out the use count.