Poker Hand Evaluator Java
I have another exercise I have to do that I really need help with. My logic is all messed up and I have no idea what to do. Here is the exercise:
Exercise 12.5 The goal of this exercise is to write a program that generates
random poker hands and classifies them, so that we can estimate the probability of
the various poker hands. Don’t worry if you don’t play poker; I’ll tell you everything
you need to know.
a. As a warmup, write a program that uses shuffleDeck and subdeck to generate
and print four random poker hands with five cards each. Did you get anything
good? Here are the possible poker hands, in increasing order of value:
pair: two cards with the same rank
two pair: two pairs of cards with the same rank
three of a kind: three cards with the same rank
straight: five cards with ranks in sequence
flush: five cards with the same suit
full house: three cards with one rank, two cards with another
four of a kind: four cards with the same rank
straight flush: five cards in sequence and with the same suit
b. Write a method called isFlush that takes a Deck as a parameter and returns a
boolean indicating whether the hand contains a flush.
c. Write a method called isThreeKind that takes a hand and returns a boolean
indicating whether the hand contains Three of a Kind.
d. Write a loop that generates a few thousand hands and checks whether they
contain a flush or three of a kind. Estimate the probability of getting one of
e. Write methods that test for the other poker hands. Some are easier than others.
You might find it useful to write some general-purpose helper methods that can
be used for more than one test.
f. In some poker games, players get seven cards each, and they form a hand with
the best five of the seven. Modify your program to generate seven-card hands
and recompute the probabilities.
And here is my code:
Re: Poker Hand Evaluator Java
I did some more thinking and I wrote a new shuffle method and I use subDeck to fill the hand with the already randomized array. However, I'm still having trouble in one part. Here is my code:
|All times are GMT +5.5. The time now is 05:43.|