This program tells you what kind of poker hand you have in a Texas Holdem game, given the 7 cards you are allowed to use.
I was trying to create a program that would check the win percentage in a Texas Holdem game, and the hardest part was finding code to check what type of poker hand you have. So I decided to make a program that would do just that.
Using the code
I made the code as easy to read as possible.
Their are many comments explaining what each part of the code does.
Some of the code in the function checkHand() is redundant. I wrote it like that to make the function easier to read.
The functions in this program are:
void checkPokerHand(int hand, int card1, int card2);
string checkCard(int card);
string checkSuit(int card);
void sort(int a);
main() Asks for the card and displays the best hand.
checkHand() takes in an array of integers with size 14.
8 = Straight Flush
7 = Four of a kind
6 = Full House
5 = Flush
4 = Straight
3 = Three of a kind
2 = Two Pair
1 = Pair
0 = High Card
(e.g. four of a kind 2s = 2)
|hand||0||Second highest card in hand|
|hand||0||Third highest card in hand|
|hand||0||Fourth highest card in hand|
|hand||0||Lowest card in hand|
|hand||card2||Second lowest card|
|hand||card3||Third lowest card|
|hand||card4||Fourth highest card|
|hand||card5||Third highest card|
|hand||card6||Second highest card|
card1 is the highest of your two cards.
card 2 is the lowest of your two cards.
checkCard(int card) returns the face value of a card in a string
(e.g. 2 returns "2" - 14 returns "A")
checkSuit(int card) returns the suit of a card in a string
(e.g. 1 returns "Hearts"; 2 returns "Clubs"; 3 returns "Diamonds"; 4 returns "Spades";)
Checks for the best poker hand when given 7 cards.