MyRandom rnd = new MyRandom();
Card c1 = cards[rnd.nextInt(cards.length)-1];
Card c2 = cards[rnd.nextInt(cards.length)-1];
System.out.println("Two cards are drawn:");
System.out.println("c1 = " + c1 + " and c2 = " + c2);
// compare c1 and c2
if (c1.compareTo(c2) < 0) {
System.out.println(c1 + " is smaller than " + c2);
}
else if (c1.compareTo(c2) == 0) {
System.out.println(c1 + " is the same as " + c2);
}
else {
System.out.println(c1 + " is larger than " + c2);
}
}
}
这个compare to 应该怎么写?
public int compareTo(Card c) {