forked from Kotlin-Polytech/FromKotlinToJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColoredPoint.java
More file actions
41 lines (34 loc) · 927 Bytes
/
Copy pathColoredPoint.java
File metadata and controls
41 lines (34 loc) · 927 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
package part2.point;
public class ColoredPoint extends Point implements Cloneable {
private final int color;
public ColoredPoint(double x, double y, int color) {
super(x, y);
this.color = color;
}
public int getColor() {
return color;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o instanceof ColoredPoint) {
ColoredPoint cp = (ColoredPoint) o;
return color == cp.color && super.equals(cp);
}
return false;
}
@Override
public ColoredPoint clone() {
try {
return (ColoredPoint) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError();
}
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + color;
return result;
}
}