Question: #include #include #include #include using namespace std; void shuffle( int [][ 13 ] ); void deal( const int [][ 13 ], const char *[], const
#include#include #include #include using namespace std; void shuffle( int [][ 13 ] ); void deal( const int [][ 13 ], const char *[], const char *[], int [][ 2 ] ); void deal2( const int [][ 13 ], const char *[], const char *[], int [][ 2 ] ); void pair1( const int [][ 13 ], const int [][ 2 ], const char *[] ); void threeOfKind1( const int [][ 13 ], const int [][ 2 ], const char *[]); void fourOfKind1( const int [][ 13 ], const int [][ 2 ], const char *[]); void flushHand1( const int [][ 13 ], const int [][ 2 ], const char *[]); void straightHand1( const int [][ 13 ], const int [][ 2 ], const char *[],const char *[]); void pair2( const int [][ 13 ], const int [][ 2 ], const char *[]); void threeOfKind2( const int [][ 13 ], const int [][ 2 ], const char *[]); void fourOfKind2( const int [][ 13 ], const int [][ 2 ], const char *[]); void flushHand2( const int [][ 13 ], const int [][ 2 ], const char *[]); void straightHand2( const int [][ 13 ], const int [][ 2 ], const char *[], const char *[]); int handstr1=0, handstr12=0; int handstr2=0, handstr22=0; int main() { const char *suit[] = { "Diamonds", "Clubs", "Hearts", "Spades" }; const char *face[] = { "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King", "Ace" }; int deck[ 4 ][ 13 ] = { 0 }; int hand[ 5 ][ 2 ] = { 0 }; srand( time( 0 ) ); // shuffle the deck shuffle( deck ); cout << "Player 1 -------- "; // deal the cards deal( deck, face, suit, hand ); // checks if Player 1's hand equal one of these: pair1( deck, hand, face); threeOfKind1( deck, hand, face); fourOfKind1( deck, hand, face ); flushHand1( deck, hand, suit); straightHand1( deck, hand, suit, face); cout << " Player 2 -------- "; deal2( deck, face, suit, hand ); // checks if Player 2's hand equal one of these: pair2( deck, hand, face); threeOfKind2( deck, hand, face); fourOfKind2( deck, hand, face); flushHand2( deck, hand, suit); straightHand2( deck, hand, suit, face); if (handstr1>handstr2) cout << " Player 1 wins!"; if (handstr1 handstr22) cout << " Player 1 wins!"; if (handstr12 s[ comp + 1 ] ) { temp = s[ comp ]; s[ comp ] = s[ comp + 1 ]; s[ comp + 1 ] = temp; } // end for loop // check if sorted columns are a straight if ( s[ 4 ] - 1 == s[ 3 ] && s[ 3 ] - 1 == s[ 2 ] && s[ 2 ] - 1 == s[ 1 ] && s[ 1 ] - 1 == s[ 0 ] ) { { cout << "The hand contains a straight consisting of "; for ( int j = 0; j < 5; ++j ) { cout << wFace[ wHand[ j ][ 1 ] ] << " of " << wSuit[ wHand[ j ][ 0 ] ] << ' '; handstr1=4; handstr12=j;}} } } // end function straightHand1 // check Player 2's hand for a straight void straightHand2( const int wDeck[][ 13 ], const int wHand[][ 2 ], const char *wSuit[], const char *wFace[] ) { int s[ 5 ] = { 0 }; // to hold a copy of wHand int temp; // copy column locations to sort for ( int r = 0; r < 5; ++r ) s[ r ] = wHand[ r ][ 1 ]; // bubble sort column locations for ( int pass = 1; pass < 5; ++pass ) for ( int comp = 0; comp < 4; ++comp ) if ( s[ comp ] > s[ comp + 1 ] ) { temp = s[ comp ]; s[ comp ] = s[ comp + 1 ]; s[ comp + 1 ] = temp; } // end for loop // check if sorted columns are a straight if ( s[ 4 ] - 1 == s[ 3 ] && s[ 3 ] - 1 == s[ 2 ] && s[ 2 ] - 1 == s[ 1 ] && s[ 1 ] - 1 == s[ 0 ] ) { { cout << "The hand contains a straight consisting of "; for ( int j = 0; j < 5; ++j ) { cout << wFace[ wHand[ j ][ 1 ] ] << " of " << wSuit[ wHand[ j ][ 0 ] ] << ' '; handstr2=4; handstr22=j;}} } } // end function straightHand
imrove playability
add highcard wins
bets
multiple turns
named players
swap out cards option
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
