Need Help proving equality with boolean

Maniacmike3128's Avatar, Join Date: Apr 2011
Newbie Member
Working on a school project and our professor has supplied us with three classes. we are to implement a fourth class called "Sprite" using a specified UML.
The UML part that I'm having trouble with looks like this:

+equals(other : Sprite) : boolean

how do i write this code? I know it needs to return a boolean, and I'm supposed to check if the sprite i have in my class equals the other sprite. I'm lost.
0
virxen's Avatar, Join Date: Nov 2009
Pro contributor
Quote:
+equals(other : Sprite) : boolean
Code:
public boolean equals(Sprite other){
   if (this==other)
       return true;//its the same object
  if (all properties values of this object==all properties values of other)
      return true;//equal objects by value
 return false;//completely different objects
}