I need to override String toString method so it woud print my deposits
I dont't know how to override it, since in makeDeposit method I pass two variables
I'm posting just a saple of my code, I'm not sure if you need the whole code
public class Bank
{
private Account []a;
private int count;
public Bank (int n)//create constructor and initialize a and count
{
if (n<0)
n=20;
a = new Account[n];//create array of account references
count = 0;
}
public boolean makeDeposit(int n, double amt)
{
boolean flag = false;
if (count<a.length)
for(int i=0; i<a.length && !flag; i++)
{
if (a[i] != null)
if (a[i].getId() == n)
{
a[i].Deposit(amt);
flag = true;
}
}
return flag;
}
I tried this
public String toString()
{
return "Deposit "+this.makeDeposit()
}
but of course I need to pass two variables with it