Question: Write a java program for the following problem Consider the following UML diagram: > SetOfCards Card # cards # max - suit - rank 1

Write a java program for the following problemWrite a java program for the following problem Consider the following UML

diagram: > SetOfCards Card # cards # max - suit - rank

1 * contains + SetOfCards() + getCards() + setCards(...) + addCard(...) +

toString() + Card(...) + getSuit() + getRank() + toString() + Deck Hand

Consider the following UML diagram: > SetOfCards Card # cards # max - suit - rank 1 * contains + SetOfCards() + getCards() + setCards(...) + addCard(...) + toString() + Card(...) + getSuit() + getRank() + toString() + Deck Hand access control: public private # protected + Deck() - createCards() + shuffle() + deal() + Hand + Hand(...) + evaluate() Create a hierarchical class structure according to the UML. 1. Enums Rank: that includes the 13 ranks of a deck of playing cards: two, three... ten, jack, queen, king, ace Suit: that includes the suits of a deck of playing cards: clubs, spades, hearts, diamonds In this assignment, Ace only has a high value (i.e. higher than King, not lower than 2) 2. The Card class has fields suit and rank of types Suit and Rank, respectively. Include one constructor: full-arg that assigns the passed suit and rank Include getters for each and override the toString method to return a string in the format of of , of , ... of ] Use StringBuilder to create this string 4. Subclasses Deck and Hand extend the SetOfCards class a) Include the following methods in the Deck class: A no-arg constructor that assigns the max to 52 and creates the deck Include a private method createCards () that creates and adds all 52 cards in a deck (i.e. each rank of each suit). Call this method in the constructor. shuffle ) that randomly orders the cards. See the Java documentation for Collections.shuffle deal() removes and returns the first card of the deck b) Include the following methods in the Hand class: A no-arg constructor that assigns the max to 5 A constructor that assigns the max and an ArrayList of Card objects to cards evaluate() that returns a String that represents the hand: Flush - all cards have the same suit Straight - five cards of consecutive rank of any suit Straight Flush - five cards of consecutive rank of the same suit One Pair - two cards of one rank and three cards of three other ranks Two Pair - two cards of one rank, two cards of another rank and one card of a third rank Three of a Kind - three cards of one rank and two cards of two other ranks Four of a Kind - four cards of one rank and one card of another rank Full House - One Pair + Three of a kind Nothing ( High) - none of the above results but indicates the highest rank in the hand, i.e., Nothing (ACE High) Additional private utility methods called in evaluate to determine the hand status (you must have at least 3 additional methods) e.g. check Flush(), etc. 5. Include a driver class called PokerHandSim that simulates the dealing of 4 hands from a deck of cards and displays the result of each Create an instance of a deck Shuffle the deck of cards, then simulate the initial hand of poker for 4 players: For each player: deal 5 cards from the to create a hand display the cards of the hand and result of the hand Sample output: Poker simulation initial hand: Player 1: [SIX of CLUBS, FOUR of DIAMONDS, ACE of CLUBS, THREE of DIAMONDS, EIGHT of DIAMONDS ] Nothing (ACE high) Player 2: [TEN of SPADES, KING of HEARTS, NINE of SPADES, SIX of DIAMONDS, TWO of CLUBS] Nothing (KING high) Player 3: [EIGHT of CLUBS, QUEEN of HEARTS, QUEEN of DIAMONDS, QUEEN of SPADES, TWO of DIAMONDS] Three of a Kind Player 4: [EIGHT of SPADES, JACK of DIAMONDS, THREE of SPADES, TEN of CLUBS, JACK of HEARTS] One Pair Number of cards remaining in deck: 32 Notes: Auxiliary arrays and ArrayLists may be used throughout the program, cards must be of type ArrayList Additional cases (all possible hand results, adding more than max number of cards, etc.) will be tested by the marker You may choose to create an enhanced enum for Rank to determine the rank value, or use the index of values of the basic enum

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!