I have some troubles in dealing with this "search()" function that i wrote. Well, i need to check if an object already exists in my stack. My object looks like this:
Boat [mLeft=[0, 0, 0], boat=L, mRight=[0, C, V]]
And my stack is something like this:
Boat [mLeft=[0, 0, 0], boat=L, mRight=[0, C, V]]
Boat [mLeft=[0, 0, 0], boat=C, mRight=[L, 0, V]]
Boat [mLeft=[0, 0, 0], boat=V, mRight=[L, C, 0]]
Boat [mLeft=[0, 0, 0], boat=0, mRight=[L, C, V]]
And this is my "search" function:
public boolean search(Boat b){
boolean r=false;
for(int i=0;i<btStack.size();i++)
{
if(btStack.elementAt(i).equals(b))
{
r = true;
}
}
return r;
}
This is never true...and i don't have any idea why. Can you help?Thanks