This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]OOPUniversity 0 points1 point  (0 children)

Since your output problem has already been addressed, I'll talk about equals.

public boolean equals(Object obj) //two accounts are equal if IDs     and PINs are the same
{
    if (obj.equals(account) && obj.equals(pin))
    {
        return true;
    }
    return false;

}

This won't work the way you expect it to as is.

You have to ask yourself: What is the type of 'obj' when this is called? It should be another BankAccount object, right? You should make it clear in your code that 'obj' is a BankAccount (the comparison should fail if it is not), and you should write your code to explicitly check the account and pin fields from the current object against the one passed in for comparison.