Our next few programming assignments will deal with the game of Poker. In this assignment we will ignore all aspects of betting, bluffing, chips, or any other decisions on the part of each player this will deal solely with representing playing cards, shuffling the deck, dealing cards into hands, and ranking hands.
Write a class, PokerCard, to represent a card in a game of Poker. A card has rank and suit, where rank is (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10 (T), Jack (J), Queen (Q), King (K), Ace (A)) and suit is (Clubs - C, Diamonds - D, Hearts - H, Spades - S). Note that Ace can be either value 1 or 14, depending on what the player wants. PokerCard objects have a natural order based on rank (suit is ignored), with Ace largest and 2 lowest, so you should implement the Comparable< PokerCard> interface.
Write a class, PokerHand, to represent a collection of 5 PokerCard objects. Define an enumeration, PokerHandCategory, with the following values: HIGH_CARD, PAIR, TWO_PAIR, THREE_OF_A_KIND, STRAIGHT, FLUSH, FULL_HOUSE, FOUR_OF_A_KIND, STRAIGHT_FLUSH. PokerHands are ordered first by category, then by individual card ranks; even the lowest hand that qualifies in a certain category defeats all hands in lower categories. All hands that do not contain a pair or some higher ranking category are considered to be in the HIGH_CARD category. For more details, please see http://en.wikipedia.org/wiki/List_of_poker_hands. Note the following details (all should be listed in Wikipedia page):
The PokerHand should implement Comparable
Write a class, PokerDeck, which contains one of each of the 52 possible PokerCard cards (no duplicates). This class needs to have the following methods:
class PokerDeck {
void shuffle(); // you may use Collections.shuffle
PokerCard draw(); // remove a card from the “top” of the deck
void draw(PokerHand targetHand); // remove a card from the “top” of the deck, add it to targetHand
}
It is highly encouraged that you write unit tests for PokerCard, PokerHand, and PokerDeck.
Write a console based program to demonstrate a very simple version of Poker for 8 players. Your program should:
1) Create a PokerDeck, and shuffle it.
2) Create 8 PokerHands
3) Deal one card to each hand at a time until every hand has 5 cards.
4) Determine which “player” (or players if there is a tie) has the best hand rank, and display the
player numbers.
5) Display, in rank order, each player and that player’s hand.
Example output:
We have 1 winning player(s): Player 2
Player 2, 3D 4S QD KD KH, PAIR, [K, Q, 4, 3]
Player 8, 2S 7H 7S 8C JH, PAIR, [7, J, 8, 2]
Player 4, 6H 6S TD QS AS, PAIR, [6, A, Q, T]
Player 7, 4D 4H 6C KS AH, PAIR, [4, A, K, 6]
Player 1, 2C 3C 3H 9H JD, PAIR, [3, J, 9, 2]
Player 6, 2H JC QC KC AD, HIGH_CARD, [A, K, Q, J, 2]
Player 5, 2D 8H 9C TH QH, HIGH_CARD, [Q, T, 9, 8, 2]
Player 3, 3S 5C 9S TC JS, HIGH_CARD, [J, T, 9, 5, 3]