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 52-card, French-suited deck. Each card has a suit (spades , hearts , diamonds , clubs ) and a rank (A =1,2,3,4,5,6,7,8,9,10, J =11, Q =12, K =13). Within the Card objects we will represent these by using numbers between 0 and 51. The rank of the Card object can be determined by rank = x /4+1. The suit of the Card object an be determined by suit = x %4(=0,=1,=2; =3). The Deck object will initially have a 52 element list containing the numbers 0 to 51 in order. Randomization Randomization should be accomplished by the java.util.Random class. Use the Random(long) constructor to get a Random object with the correct seed value. Use the nextInt(int) 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 Card(int)- uses an integer value in the range of [0-51] 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 rank/suit combination as a two or three character string (like QD,3S, or 10C) Deck - contains 52 distinct Card objects public Deck(int)- creates a sorted list of Card objects from AS to KC and a Random object with the parameter as a seed public void shuffle(int n)- swaps two random Card objects with each other n times public Hand deal()- returns a Hand object with the first 5 objects from the list of Card objects Hand - contains 5 distinct Card objects public Hand(Card[])- 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.shuffle(int)- the user inputs an integer. The function generates two random numbers between 0 and 51, 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 5 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 00.00000% Four of a Kind 00.00000% Full House 00.00000% Flush 00.00000% Straight 00.00000% Three of a Kind 00.00000% Two Pair 00.00000% One Pair 00.00000% High Card 00.00000% NOTES! Cards of rank 1(Aces) are always low (i.e.<2) Your initial deck should be in order (0-51). 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 676. 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 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 Programming Questions!