Debug constructor to make testing the class easier. Various hands are created to
the methods in this class.
Type 1 Three of a Kind
Type 2 Two pair
Type 3 One pair
Type 4 Straight
Type 5 Flush
Type 6 Full House
Parameters:
handType - Allows for selecting different PokerHands for testing.
Determines the number of different cards in the PokerHand
Precondition: Hand is sorted.
Returns:
the number if different cardNum values. Two pair would return a 3.
four of a kind would return a 2, a straight would return a 5, full house would
return 2.
returns false otherwise.
isFlush
public boolean isFlush()
Determines if all five cards are of the same suit.
Precondition: none
Returns:
true if all five Cards have the same suitNum values.
returns false otherwise.
isFullHouse
public boolean isFullHouse()
Determines if the hand is a full house.
Precondition : Hand is sorted
Returns:
true if there are two different cards and second and fourth
cards do not contain the same cardNum value.
isOnePair
public boolean isOnePair()
Determines if the hand has exactly one pair.
Precondition: hand is sorted.
Returns:
true if there are exactly four different cards.
returns false otherwise.
isStraight
public boolean isStraight()
Determines if the hand is a straight. At this point assume Ace is always high.
Precondition: Hand is sorted.
Returns:
true if the hand has five different cards and the difference between the
first cardNum and the last cardNum is 4.
returns false otherwise.
isThreeOfKind
public boolean isThreeOfKind()
Determines if a hand contains three of a kind only. A full house or
four of a kind would return false.
Precondition: hand is sorted.
Returns:
true if there are three different cards (Full house would return 2
different cards as would four of a kind.) and the first and third card have the same
cardNum values or the second and fourth card have the same cardNum values or the third
and fifth cardNum values are the same.
returns false otherwise.
isTwoPair
public boolean isTwoPair()
Determines if a hand contains two pair only.
Precondition: hand is sorted
Returns:
true if there are three different cards and the
first and third have different cardNum values and
second and fourth have different cardNum values and
third and fifth have different cardNum values.
returns false otherwise.
showHand
public void showHand()
Outputs the PokerHand to the monitor.
sortHand
public void sortHand()
Sorts the PokerHand according to the cardNum. cardNum values :
Ace - 14, King - 13, Queen - 12, Jack - 11, Ten - 10, Nine - 9, ...
It sorts the hand from smallest cardNum value to largest cardNum value.
This method must be working to implement the methods to determine the
type of card hand.
This method should be call at the conclusion of all constructors.