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 (again)
It would be nice to have the toString()
method
show 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 be declared to be public
.
The method must look like this:
public String toString() { }
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: " + ; } }
Modify the method so that it also prints out the use count.