java public int compareTo()

 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) {

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^