card_games.h
------------------
Line 11: Card needs a default constructor (and an implementation of it).
functions.cpp
----------------
StudPoker::deal() needs work.
1) No need to pass m_players in as an argument. m_players is a member of StudPoker.
2) You declare m_plays again at line 49.
3) The two loops should be nested. MAX_CARDS should be the outer loop.
4) Line 42: hand.size(). That's the number of cards current in the hand, if hand were a vector. It's not, it's an int (line 40). The loop limit here should be i<5.
4) Line 44: When you draw a card, you have to put it somewhere.
1 2 3 4 5 6 7 8 9 10 11 12 13
|
void StudPoker::Deal ()
{ Card card;
cout << "Dealing..." << endl;
for (int i=0; i<MAX_CARDS; i++)
{ for (int j=0; j<m_num_players; j++)
{ card = m_deck.Draw();
m_player[j].add_card (card);
}
// Accept bets after one card dealt to each player.
betting_round();
}
}
|
what's the best way to do the find_high_rank() |
Here's a starter:
1 2 3 4 5 6 7 8
|
// Return the value of the highest card
int Hand::find_high_rank () const
{ int high_rank = 0;
for (unsigned i=0; i<m_hand.size(); i++)
high_rank = max(high_rank, m_hand[i].get_rank());
return high_rank;
}
|
Note: This only returns the highest card in the hand. This won't work for situations like full house where you want the higher thresome, or two pair where you want the higher pair. Note that two pair could have the same higher pair, then the lower pair determines. e.g. KK55, KK99.
functions.cpp
-----------------
Lines 74-76,89,96,104,112: These are recursive. i.e. is_four calls itself. Will cause an endless loop and stack overflow.
Line 82: A full house is a threesome and a pair, not a threesome and two pair.
StudPoker needs a method to input the number of players.
main.cpp
-----------
main() needs to call StudPoker's function to determine the number of players.