Hi. I posted yesterday, but didn't get a good enough idea of how to proceed. I have four classes in a card game: Card, Deck, Player, and Game. The Card class is as follows:
Code:
class Card
{
public:
Card();
void setValue(int);
int getValue();
private:
int value;
};
Class Deck should not have a private section, or any data members.
Code:
class Deck
{
public:
Deck();
Card randomCard;
int shuffle();
};
The code for the last two classes is:
Code:
class Player
{
public:
Player();
void enterName();
void setName(string);
string getName();
int getTotal();
int addCardValue(Card);
private:
string name;
int total;
};
class Game
{
public:
void enterPlayerInfo();
void playGame();
Player getWinner();
void showGame(Player);
private:
void drawPlayer();
void drawDealers();
Player user;
Player computer;
};
There are a few things that I am having difficulty with. As someone suggested yesterday (I haven't posted to forums such as these for a while), I try to ask one question at a time.
I'm not sure how to get a new randomly drawn card to show up.
I am given the following to put into the Main function:
Code:
int main()
{
srand( (unsigned)time( NULL ) );
return 0;
}
My shuffle() member function looks like this:
Code:
int Deck::shuffle()
{
return rand() % 10;
}
Now, I am not sure where to go from here. I was thinking of trying to incorporate the accessor functions in Card, to set a new number each time. I'm puzzled though. Thanks in advance for any suggestions. Steve