Card implements Comparable<Card> { @Override public int compareTo(Card o) { Card otherCard = o; if (value.equals(otherCard.getValue())) { return suit.compareTo(otherCard.getSuit()); } return value.compareTo(otherCard.getValue()); } Card(String card); Value getValue(); Suit getSuit(); @Override boolean equals(Object other); @Override int compareTo(Card o); @Override int hashCode(); @Override String toString();  }
@Test public void with_the_same_suit_two_card_should_be_ordered_by_value() throws Exception { Card fiveHeart = new Card("5♥"); Card sixHeart = new Card("6♥"); assertThat(fiveHeart.compareTo(sixHeart)).isLessThan(0); }
@Test public void with_the_same_value_two_card_should_be_ordered_by_suit() throws Exception { Card fiveHeart = new Card("5♥"); Card fiveDiamond = new Card("5♦"); assertThat(fiveHeart.compareTo(fiveDiamond)).isLessThan(0); }
@Test public void with_different_values_and_suit_two_card_should_be_ordered_by_value_then_by_suit() throws Exception { Card fourDiamond = new Card("4♦"); Card fiveHeart = new Card("5♥"); assertThat(fourDiamond.compareTo(fiveHeart)).isLessThan(0); }