General

Chat

Poker Game Hand evaluator

Hi all, I need help with evaluating hands for a Poker project. So all the methods take in an Array of type Card and it is supposed to evaluate your hand of 5 cards to see if any match the description.
What I need:

public static boolean hasPair(Card[] cards)
public static boolean hasTwoPair(Card[] cards)
public static boolean hasThreeOfAKind(Card[] cards)
public static boolean hasStraight(Card[] cards)
public static boolean hasFlush(Card[] cards)
public static boolean hasFullHouse(Card[] cards)
public static boolean hasFourOfAKind(Card[] cards)
public static boolean hasStraightFlush(Card[] cards)

Important: Each of these methods checks whether or not the set of cards satisfies the given poker hand, but it does not care if it could also satisfy a better hand. For example, if the current hand is

<Ace of diamonds, Ace of spades, Ace of hearts, Jack of Spades, Jack of Diamonds>

then the results of calling each method should be as indicated below:

hasPair -- true (there is at least one pair)
hasTwoPair -- true (there are two pairs of distinct values)
hasThreeOfAKind -- true (there are three Aces)
hasStraight -- false
hasFlush -- false
hasFullHouse -- true (there are three Aces and two Jacks -- that makes a "full house&quot
hasFourOfAKind -- false
hasStraightFlush -- false
Important: In order for a hand to qualify as "Two Pair", it must have two pairs of distinct values -- in particular, having four-of-a-kind does not also count as two pair. For example, if the current hand is

<2 of diamonds, 2 of spades, 2 of hearts, 2 of clubs, 9 of spades>

then the results of calling each method should be as indicated below:

hasPair -- true (there is at least one pair)
hasTwoPair -- false (there are not two pairs of distinct values)
hasThreeOfAKind -- true (there are three 2's)
hasStraight -- false
hasFlush -- false
hasFullHouse -- false
hasFourOfAKind -- true (there are four 2's)
hasStraightFlush -- false

Thanks for the help.

November 18, 2015

1 Comment • Newest first

Qubii

http://goo.gl/rhV8ko

Reply November 18, 2015