public class Card { private Suit suit; private Rank rank; public Card(Suit suit, Rank rank) { this.suit = suit; this.rank = rank; } public Suit getSuit() { return suit; } public Rank getRank() { return rank; } public String getSuitAsString() { switch (this.suit) { case DIAMONDS: return "♦"; case CLUBS: return "♣"; case HEARTS: return "♥"; case SPADES: return "♠"; default: return ""; } } public String getRankAsString() { switch (this.rank) { case TWO: return "2"; case THREE: return "3"; case FOUR: return "4"; case FIVE: return "5"; case SIX: return "6"; case SEVEN: return "7"; case EIGHT: return "8"; case NINE: return "9"; case TEN: return "10"; case JACK: return "J"; case QUEEN: return "Q"; case KING: return "K"; case ACE: return "A"; default: return ""; } } public String toString() { return getRankAsString() + getSuitAsString(); } public int compareTo(Card other) { return getRankAsString().compareTo(other.getRankAsString()); // For this game, the comparison is based on only // ranks with the suit playing no role in the // comparison } }