View Javadoc

1   package de.jos.game.objects;
2   
3   import org.apache.commons.lang.builder.HashCodeBuilder;
4   import org.apache.commons.lang.builder.ToStringBuilder;
5   
6   public class Position {
7   
8     private int x;
9     private int y;
10  
11    public Position(int x, int y) {
12      this.x = x;
13      this.y = y;
14    }
15  
16    public boolean equals(Object obj) {
17      if (obj == null || !(obj instanceof Position)) {
18        return false;
19      }
20      Position castOther = (Position) obj;
21  
22      return (getX() == castOther.getX() && getY() == castOther.getY());
23    }
24  
25    public int hashCode() {
26      return new HashCodeBuilder().append(Integer.valueOf(x)).append(Integer.valueOf(y)).toHashCode();
27    }
28  
29    public String toString() {
30      return ToStringBuilder.reflectionToString(this);
31    }
32  
33    public int getX() {
34      return x;
35    }
36  
37    public void setX(int x) {
38      this.x = x;
39    }
40  
41    public int getY() {
42      return y;
43    }
44  
45    public void setY(int y) {
46      this.y = y;
47    }
48  
49  }