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.
|
Pro contributor
|
![]() |
| 9Apr2011,03:53 | #2 |
|
Quote:
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
}
|

