I have the following listing, which is CardRank
public enum CardRank
{
DEUCE('2'), TREY('3'), FOUR('4'), FIVE('5'), SIX('6'), SEVEN('7'),
EIGHT('8'), NINE('9'), TEN('T'), JACK('J'), QUEEN('Q'), KING('K'),
ACE('A');
private char symbol;
private CardRank(char symbol)
{
this.symbol = symbol;
}
public char getSymbol()
{
return this.symbol;
}
}
CardRankappears in ascending order. I need to compare ranks to find out which rank is greater than the other. I can use the operator >with numeric values, but not with char values.
if (card.getRank().getSymbol() > anotherCard.getRank().getSymbol()) {
System.out.println("true");
} else {
System.out.println("false");
}
Any ideas?
source
share