-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.java
More file actions
56 lines (43 loc) · 892 Bytes
/
Copy pathPoint.java
File metadata and controls
56 lines (43 loc) · 892 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
package com.javaex.api.objectclass.ex03;
public class Point implements Cloneable {
private int x;
private int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public String toString() {
return "Point(" + x + ", " + y +")";
}
@Override
public boolean equals(Object obj) {
if ( obj instanceof Point) {
Point other = (Point)obj;
return x == other.x && y == other.y;
}
return super.equals(obj);
}
public Point getClone() {
Point clone = null;
try {
clone = (Point)clone();
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return clone;
}
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;
}
}