-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoor.java
More file actions
38 lines (34 loc) · 710 Bytes
/
Coor.java
File metadata and controls
38 lines (34 loc) · 710 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
public class Coor {
private int[] coor = new int[2];
// constructors
public Coor() {
}
public Coor(int x, int y) {
coor[0] = x;
coor[1] = y;
}
// setters
public void setX(int x) {
coor[0] = x;
}
public void setY(int y) {
coor[1] = y;
}
// getters
public int x() {
return coor[0];
}
public int y() {
return coor[1];
}
public int[] matrix() {
return coor;
}
@Override
public boolean equals(Object obj) {
return ((Coor) obj).x() == coor[0] && ((Coor) obj).y() == coor[1];
}
public String toString() {
return coor[0] + ", " + coor[1];
}
}