PDA

Click to See Complete Forum and Search --> : 1:45 PM, due in 3 hours and still can't figure it out.


Colora
Dec 11th, 2000, 12:46 PM
I've been trying to get a dos based poker hand program working for over a week. I'm in a lecture series class so there's no computers in the classroom, and my teacher has office hours only one hour before class starts. I'm using VC++ 6.0.

It's a long code, not sure anyone wants to have to scroll down to look at it. Here's the first part:

#include <iostream.h>
#include <iomanip.h>
#include <cstdlib>
#include <ctime>
void shuffle( int [][ 13 ] );
void deal( const int [][ 13 ], const char *[], const char *[] );

int main()
{
const char *suit[ 4 ] =
{ "Hearts", "Diamonds", "Clubs", "Spades" };
const char *face[ 13 ] =
{ "Ace", "Deuce", "Three", "Four",
"Five", "Six", "Seven", "Eight",
"Nine", "Ten", "Jack", "Queen", "King" };
int deck[ 4 ][ 13 ] = { 0 };
srand( time( 0 ) );
shuffle( deck );
deal( deck, face, suit );
return 0;
}

That works fine. The shuffle and deal functions work fine, it outputs 5 cards - face value and suit. The last function is supposed to check the 5 cards for 1 pair, 2 pair, 3 of a kind, 4 of a kind, a flush, or a lousy hand, and report back to the output screen (dos) the results. It is one hand, not something you're actually playing against anyone else. The output occurs in the deal function (only the part I'm talking about is posted):

if ( wDeck[ row ][ column ] == card )
void evalHand(int p[], int s);
cout << setw( 5 ) << setiosflags( ios::right )
<< wFace[ column ] << " of "
<< setw( 8 ) << setiosflags( ios::left )
<< wSuit[ row ]
<< ( card % 2 == 0 ? '\n' : '\t' );

cout<<endl<<endl;
}

and that works fine too. I have a function called evalHand to evaluate the cards, and within it, an if/else to create a pair counter to determine how many pairs so that if there are less than 3 pairs, it checks for 2 pair, a flush, or a "lousy hand."

Where in tarnation do I place this evalHand, and how do I call it? I've tried a bunch of different things. Sometimes I get errors regarding the column and rows in the above deal function statement, and sometimes it'll run but not output anything about the hand - just list the 5 cards.

Any help is appreciated, I'm going nuts.

HarryW
Dec 11th, 2000, 02:01 PM
if ( wDeck[ row ][ column ] == card )
void evalHand(int p[], int s);


This is a function declaration, not a function call. You don't write the return type when you call a function, and you pass parameters in, you don't write the types the function expects. You need to write something like this (I'm not sure what the parameters for evalHand are):


if ( wDeck[ row ][ column ] == card )
evalHand(yourHand, someIntVariable);