java - Comparing rank in an enum - Stack Overflow
if (card.getRank().compareTo(anotherCard.getRank()) > 0)
is what you need.
You may alwo use the ordinal:
if (card.getRank().ordinal() > anotherCard.getRank().ordinal())
Enums have a natural ordering defined by their ordinal. And the ordinal of an enum is attributed based on its position in the declaration. So DEUCE has ordinal 0, TREY has ordinal 1, etc.
Read full article from java - Comparing rank in an enum - Stack Overflow
No comments:
Post a Comment