public final class Ball1 implements Comparable<Ball1> {
private final int number;
private final BallColor1 color;
public Ball1(int num, BallColor1 color) {
this.number = num;
this.color = color;
}
public int getNumber() {
return number;
}
public BallColor1 getColor() {
return color;
}
@Override
public String toString() {
return "(" + number + "," + color + ")";
}
public int compareTo(Ball1 ball1) {
int res=this.color.compareTo(ball1.color);
if(res==0) {
res=this.number-ball1.number;
}
res*=-1;
return res;
}
}