01219343/unit/poker
Follow the TDD steps to write these classes.
Card
A card has a rank (A,1,...,9,10,J,Q,K) and a suit (S,H,D,C) (see suit).
Implement class Card
that supports the following methods:
- Construction with rank and suit as strings. (This might not be an efficient way to represent ranks and suits, but it simplifies the exercise.) For example:
Card card = new Card("10","S");
- Getters:
getRank
andgetSuit
hasSameRank
hasSameSuit
- The class should implement interface
Comparable<Card>
so that we can easily sort the cards. Add that interface to the class and implement a public methodint compareTo(Card c)
.
Hand
Use reference of poker hands from wikipedia.