I'm trying to write program that evaluates a poker hand and returns whether or not it contains a straight, flush, pair, etc. I've got every method except one to work. I cannot figure out how to correctly write the method that determines whether or not there is a straight. Every time I try to complile the code, I get an error saying "DeckOfCards.cpp ISO C++ forbids comparison between pointer and integer."
DeckOfCards::DeckOfCards()
{
char *suitValue[ 4 ] = { "Hearts", "Diamonds", "Clubs", "Spades" };
char *faceValue[ 13 ] = { "Ace", "Deuce", "Three", "Four", "Five",
"Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" };
// initialize suit
for ( int i = 0; i < 4; i++ )
suit[ i ] = suitValue[ i ];
// initialize face
for ( int i = 0; i < 13; i++ )
face[ i ] = faceValue[ i ];
// loop through rows of deck
for ( int row = 0; row <= 3; row++ )
{
// loop through columns of deck for current row
for ( int column = 0; column <= 12; column++ )
{
deck[ row ][ column ] = 0; // initialize slot of deck to 0
} // end inner for
} // end outer for
srand( time( 0 ) ); // seed random number generator
} // end DeckOfCards default constructor
void DeckOfCards::shuffle()
{
int row; // represents suit value of card
int column; // represents face value of card
// for each of the 52 cards, choose a slot of the deck randomly
for ( int card = 1; card <= 52; card++ )
{
do // choose a new random location until unoccupied slot is found
{
row = rand() % 4; // randomly select the row
column = rand() % 13; // randomly select the column
} while( deck[ row ][ column ] != 0 ); // end do...while
// place card number in chosen slot of deck
deck[ row ][ column ] = card;
} // end for
} // end function shuffle
// deal a five card poker hand
void DeckOfCards::deal()
{
// loop to distrubute the cards
for ( int card = 1; card < 6; card++ )
for ( int row = 0; row <= 3; row++ )
for ( int column = 0; column <= 12; column++ )
if ( deck[ row ][ column ] == card )
{
hand[ handPos ][ 0 ] = row;
hand[ handPos ][ 1 ] = column;
cout << setw( 5 ) << face[ column ] << (" of ")
<< setw( 8 ) << left << suit[ row ] << endl;
handPos++;
} // end if
} // end deal
void DeckOfCards::straight()
{
for ( int i = 0; i < 4; i++ )
{
if ( hand [ i ] == 1 && hand [ i ] == 2 && hand [i] == 3 &&
hand [ i ] == 4 && hand [ i ] == 5 )
{
cout <<("\n You have a straight");
}
else if ( hand [ i ] == 2 && hand [ i ] == 3 && hand [i] == 4 &&
hand [ i ] == 5 && hand [ i ] == 6 )
{
cout <<("\nYou have a straight");
}
else if ( hand [ i ] == 3 && hand [ i ] == 4 && hand [i] == 5 &&
hand [ i ] == 6 && hand [ i ] == 7 )
{
cout <<("\nYou have a straight");
}
else if ( hand [ i ] == 4 && hand [ i ] == 5 && hand [i] == 6 &&
hand [ i ] == 7 && hand [ i ] == 8)
{
cout <<("\nYou have a straight");
}
else if ( hand [ i ] == 5 && hand [ i ] == 6 && hand [i] == 7 &&
hand [ i ] == 8 && hand [ i ] == 9 )
{
cout <<("\nYou have a straight");
}
else if ( hand [ i ] == 6 && hand [ i ] == 7 && hand [i] == 8 &&
hand [ i ] == 9 && hand [ i ] == 10 )
{
cout <<("\nYou have a straight");
}
else if ( hand [ i ] == 7 && hand [ i ] == 8 && hand [i] == 9 &&
hand [ i ] == 10 && hand [ i ] == 11 )
{
cout <<("\nYou have a straight");
}
else if ( hand [ i ] == 8 && hand [ i ] == 9 && hand [i] == 10 &&
hand [ i ] == 11 && hand [ i ] == 12 )
{
cout <<("\nYou have a straight");
}
else if ( hand [ i ] == 9 && hand [ i ] == 10 && hand [i] == 11 &&
hand [ i ] == 12 && hand [ i ] == 13 )
{
cout <<("\nYou have a straight");
}
}
}