Question: Poker Dealing and Ranking Hands CS211 Programming Assignment 2 Our next few programming assignments will deal with the game of Poker. In this assignment we

Poker Dealing and Ranking Hands CS211 Programming Assignment 2 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. Part I Infrastructure 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 interface. PokerCard.toString() should print as a two character string, rank then suit. E.g., 2C for two of clubs, TS for ten of spades, QH for queen of hearts, etc. The class should also include a constructor that takes a String, e.g. PokerCard card = new PokerCard(2C); 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): 7 7 5 3 2 > 6 6 A 3 2 (a pair of 7s is better than a pair of 6s) 7 7 A 3 2 > 7 7 Q 3 2 (both players have a pair of 7s, but an Ace is higher than a Queen) Q Q Q 2 2 > J J J A A (both players have a full house, but three queens is better than three jacks) K Q J T 9 > T 9 8 7 6 (both players have a straight, but the King is higher than the ten). T 9 8 7 6 > 5 4 3 2 A (if the ace is used as a one, it is not considered a high card). The PokerHand should implement Comparable, as well as the following methods: void addCard(PokerCard card) String toString() should print each card, separated by a space, followed by the category. For example, 7H 7S AH 4H 2C, HIGH_CARD 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. Part II SimplePokerGame 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 players 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] Grading Criteria PokerCard implementation (including Comparable) 20 PokerHand implementation 20 PokerHand implements Comparable 20 PokerDeck implementation 10 SimplePokerGame works 10 Code is readable and follows coding style 20 Bonus: Every JUnit test +0.5/test (+5 max)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!