Ok the problem is to have a typical card shuffling and dealing program but to also display the color of each dealt card and to indicate a face card with an asterick.
Most of the program is done but I am having a few problems- mainly after declaring a boolean variable (isFace) and assigning true to the variable if the card is a face card and false if it isn't.
I think its simple but it just isn't clicking with me. Any suggestions will be appreciated.
I know I need to use strcmp but I don't understand what I'm comparing. I'm not asking for people to do my work- just helpful hints and suggestions
Thanks,
Code:
#include <iostream>
using std::cout;
using std::endl;
using std::ios;
#include <iomanip>
using std::setiosflags;
using std::setw;
#include <cstring>
#include <ctime>
#include <cstdlib>
void deal( const int [][ 13 ], const char *[],
const char *[], const char *[] );
void shuffle( int [][ 13 ] );
int main()
{
const char *suit[ 4 ] =
{ "Hearts", "Clubs", "Diamonds", "Spades" };
const char *face[ 13 ] =
{ "Ace", "Deuce", "Three", "Four",
"Five", "Six", "Seven", "Eight",
"Nine", "Ten", "Jack", "Queen", "King" };
const char *color[2] = { "Red", "Black"};
int deck[ 4 ][ 13 ] = { 0 };
shuffle( deck );
deal( deck, face, suit, color );
return 0;
}
void deal( const int wDeck[][ 13 ], const char *wFace[],
const char *wSuit[], const char *wColor[] )
{
for ( int card = 1; card <= 52; card++ )
for ( int row = 0; row <= 3; row++ )
for ( int column = 0; column <= 12; column++ )
if ( wDeck[ row ][ column ] == card )
{
bool isFace;
HERES MY PROBLEM
/* write statement to determine if the current
card is a face card. If it is, assign true
to variable isFace. If it is not, assign
false to variable isFace */
cout << setw( 5 ) << setiosflags( ios::right )
<< wFace[ column ] << " of "
<< setw( 8 ) << setiosflags( ios::left )
<< wSuit[ row ] << " ";
cout << wColor[column] << endl;
/* Write statement to display an asterick
if it is necessary */
cout << ( card % 2 == 0 ? '\n' : '\t' );
}
}
void shuffle( int wDeck[][ 13 ] )
{
int row, column;
srand( time( 0 ) );
for ( int card = 1; card <= 52; card++ ) {
do {
row = rand() % 4;
column = rand() % 13;
} while( wDeck[ row ][ column ] != 0 );
wDeck[ row ][ column ] = card;
}
}