Deque<Card>我想使用Card类方法对集合的内容进行排序getRealValue()。
public class Card implements Comparable<Card> {\n private final int value;\n private final CardType cardType;\n\n public Card(int value, CardType cardType) {\n this.value = value;\n this.cardType = cardType;\n }\n\n public int getRealValue() {\n int realValue = this.value == 1 ? 52 : 0;\n return realValue + this.value * 4 + this.cardType.ordinal();\n }\n\n public int compareTo(Card o) {\n return this.getRealValue() - o.getRealValue();\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n这是我的 CardType 枚举
\n\npublic enum CardType {\n CLUB("\xe2\x99\xa3"),\n SPADE("\xe2\x99\xa0"), \n HEART("\xe2\x99\xa5"), …Run Code Online (Sandbox Code Playgroud)