Package net.n1da.dev.euler.helper.poker
Class Hand
- java.lang.Object
-
- net.n1da.dev.euler.helper.poker.Hand
-
public class Hand extends java.lang.Object
Objects of this class representing a hand ofPoker Cards
.- Since:
- 17.08.2016 07:11:36
- Author:
- Nico Danneberg
-
-
Method Summary
Modifier and Type Method Description boolean
beats(Hand h)
Checks if the current hand beats the given one by comparing thevalue
of both hands.long
getValue()
The complete value of a five card poker hand can be represented in a 5-digit big hexadecimal number.boolean
isFlush()
Tests if this hand is a Flush.boolean
isFourOfAKind()
Tests if this hand is a Four of a Kind.boolean
isFullHouse()
Tests if this hand is a Full House.boolean
isHighCard()
Tests if this hand is just a High Card.boolean
isOnePair()
Tests if this hand is a One Pair.boolean
isRoyalFlush()
Tests if this hand is a Royal Flush.boolean
isStraight()
Tests if this hand is a Straight.boolean
isStraightFlush()
Tests if this hand is a Straight Flush.boolean
isThreeOfAKind()
Tests if this hand is a Three of a Kind.boolean
isTwoPairs()
Tests if this hand is a Two Pairs.java.lang.String
toString()
Creates a string representation of this hand.
-
-
-
Method Detail
-
beats
public boolean beats(Hand h)
Checks if the current hand beats the given one by comparing thevalue
of both hands.- Parameters:
h
- another hand- Returns:
- true if the current hand's value is greater than the given hand's
- See Also:
getValue()
-
getValue
public long getValue()
The complete value of a five card poker hand can be represented in a 5-digit big hexadecimal number. Here this number is calculated.- Returns:
- the numeric value of the hand
-
isFlush
public boolean isFlush()
Tests if this hand is a Flush.- Returns:
- true if all cards has the same suit
- See Also:
Card.getSuit()
-
isFourOfAKind
public boolean isFourOfAKind()
Tests if this hand is a Four of a Kind.- Returns:
- true if fours cards has the same value
- See Also:
Card.getValue()
-
isFullHouse
public boolean isFullHouse()
Tests if this hand is a Full House.- Returns:
- true if three cards has the same value and the other two has an equal value, too
- See Also:
Card.getValue()
-
isHighCard
public boolean isHighCard()
Tests if this hand is just a High Card.- Returns:
- true if all cards' values exist only once
- See Also:
Card.getValue()
-
isOnePair
public boolean isOnePair()
Tests if this hand is a One Pair.- Returns:
- true if only two cards has the same value
- See Also:
Card.getValue()
-
isRoyalFlush
public boolean isRoyalFlush()
Tests if this hand is a Royal Flush.- Returns:
- true if this hand is a Flush, and a Straight, and the lowest card is a ten
- See Also:
isFlush()
,isStraight()
-
isStraight
public boolean isStraight()
Tests if this hand is a Straight.- Returns:
- true if all cards' value are in an consecutive order
- See Also:
Card.getNumericValue()
-
isStraightFlush
public boolean isStraightFlush()
Tests if this hand is a Straight Flush.- Returns:
- true if this hand is a Flush and a Straight
- See Also:
isFlush()
,isStraight()
-
isThreeOfAKind
public boolean isThreeOfAKind()
Tests if this hand is a Three of a Kind.- Returns:
- true if three cards has the same value and the rest is no pair
-
isTwoPairs
public boolean isTwoPairs()
Tests if this hand is a Two Pairs.- Returns:
- true if exactly two different cards' values exist twice
-
toString
public java.lang.String toString()
Creates a string representation of this hand.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string a combination of all cards in this hand
- See Also:
Card.toString()
-
-