-
Notifications
You must be signed in to change notification settings - Fork 1
/
Point.java
61 lines (53 loc) · 1.1 KB
/
Point.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package CheckersFramework;
/**
*
* @author Hendrik
*/
public class Point {
private final int x;
private final int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
/**
* @return the x coordinate
*/
public int getX() {
return x;
}
/**
* @return the y coordinate
*/
public int getY() {
return y;
}
/**
* Check for equality with another object.
*
* @param o the object to check for equality
* @return whether the object o is equal to this point
*/
@Override
public boolean equals(Object o) {
if (o == null || o.getClass() != getClass()) {
return false;
} else {
Point p = (Point) o;
return x == p.getX()
&& y == p.getY();
}
}
/**
* Standard hash code imlementation.
*
* @return a hash code for this point
*/
@Override
public int hashCode() {
int hash = 5;
hash = 31 * hash + this.x;
hash = 31 * hash + this.y;
return hash;
}
}