-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.java
More file actions
58 lines (47 loc) · 763 Bytes
/
Point.java
File metadata and controls
58 lines (47 loc) · 763 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
52
53
54
55
56
57
58
/**
* @author Anuj
*
*/
public class Point implements Comparable<Point> {
private int x;
private int y;
public Point() {
setX(0);
setY(0);
}
public Point(int x, int y) {
this.setX(x);
this.setY(y);
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
@Override
public int compareTo(Point o) {
if (this.y == o.getY()) {
return 0;
}
else {
return this.y > o.getY() ? 1 : -1;
}
}
@Override
public boolean equals(Object o) {
if (o != null && o instanceof Point)
return (this.compareTo((Point)o) == 0);
return false;
}
@Override
public String toString() {
return "(" + x + ", " + y + ")";
}
}