Question: Please write this code in java: - Poker is an easy game to learn and a hard game to win. Each player is dealt a
Please write this code in java: Poker is an easy game to learn and a hard game to win. Each player is dealt a "hand" of five cards. The hands are compared see below and a winner is determined. For this project you will write a program that will generate multiple five card hands from a shuffled deck of cards and then keep track of what type of hand it is providing a count and a percentage at the end. Card Representation Modern poker uses a standard card, Frenchsuited deck. Each card has a suit spades hearts diamonds clubs and a rank A J Q K Within the Card objects we will represent these by using numbers between and The rank of the Card object can be determined by rank x The suit of the Card object an be determined by suit x ; The Deck object will initially have a element list containing the numbers to in order. Randomization Randomization should be accomplished by the java.util.Random class. Use the Randomlong constructor to get a Random object with the correct seed value. Use the nextIntint function to generate an appropriate value. You must randomize in exactly this way or your outputs will not match the test cases. Objects You will need to be able to create the following objects: Card contains the suit and rank of an individual card and implements the Comparable interface public Cardint uses an integer value in the range of to initialize the rank and suit of the card public int getSuit returns the value for the suit of the card public int getRank returns the value for the rank of the card public String toString returns the ranksuit combination as a two or three character string like QDS or C Deck contains distinct Card objects public Deckint creates a sorted list of Card objects from AS to KC and a Random object with the parameter as a seed public void shuffleint n swaps two random Card objects with each other n times public Hand deal returns a Hand object with the first objects from the list of Card objects Hand contains distinct Card objects public HandCard creates a sorted hand from a five element Card array public Card getCards returns a sorted array of Card objects public HandType getHandType returns the enum value representing the type of the Hand object Functions Deck.shuffleint the user inputs an integer. The function generates two random numbers between and and then swaps the values in those positions in the list. This random swap occurs a number of times equal to the integer that was input. Hand.getHandType The function returns an enumerated value based on the type of hand: StraightFlush, FourOfAKind, FullHouse, Flush, Straight, ThreeOfAKind, TwoPair, OnePair, HighCard, The main function Your main function should do the following: prompt the user for a seed for the random number generator: Enter the seed value : generate and display sorted hands prompts the user for the number of hands to analyze: Enter the number of hands : generate that number of hands and analyze them print a formatted list of how many hands fall into each type and the percentage of total hands in each type Straight Flush Four of a Kind Full House Flush Straight Three of a Kind Two Pair One Pair High Card NOTES! Cards of rank Aces are always low ie Your initial deck should be in order You will shuffle many times, but never reset sort the deck The random number generator should be seeded only once and with the user entered value The random function should only be used to "shuffle" the deck. When you shuffle the number of swaps int argument should be When generating a hand you should always shuffle before a deal You should always display a hand in sorted order The program should be able to handle any number of hands to
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
