-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoordinate.java
More file actions
51 lines (44 loc) · 816 Bytes
/
Coordinate.java
File metadata and controls
51 lines (44 loc) · 816 Bytes
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
import java.util.Objects;
public class Coordinate {
private int x;
private int y;
public static Coordinate EmptyCoordinate = new Coordinate(-1,-1);
public Coordinate(int x, int y) {
this.x = x;
this.y = y;
}
int getX() {
return this.x;
}
int getY() {
return this.y;
}
void setX(int x) {
this.x = x;
}
void setY(int y) {
this.y = y;
}
void setXY(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public boolean equals(Object o) {
if (o == this)
return true;
if (!(o instanceof Coordinate)) {
return false;
}
Coordinate coordinate = (Coordinate) o;
return x == coordinate.x && y == coordinate.y;
}
@Override
public int hashCode() {
return Objects.hash(x, y);
}
@Override
public String toString(){
return "Coordinate: ("+this.x+","+this.y+")";
}
}