Edit: I decided to have it shuffle the deck first like you guys said. Here's drawCard() so far:
Code:
int drawCard() {
static int deck[52] = {1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11,11,11,11,12,12,12,12,13,13,13,13};
static int cardToDraw = 0;
int drawnCard;
if (cardToDraw < 52) {
drawnCard = deck[cardToDraw];
deck[cardToDraw] = 0;
cardToDraw++;
}
else {
shuffleDeck();
cardToDraw = 0;
}
cout<< "cardToDraw = "<< cardToDraw<< ".\n";//Debugging line.
return drawnCard;
}
I'll have to learn about passing variables between functions, and I haven't written shuffleDeck() yet, but does this look good so far?
Edit: Would it be better to just set deck[52] as a global variable? I don't really understand how to pass variables between functions. I wrote part of shuffleDeck(), but I can't continue until I figure this out.
Code:
void shuffleDeck() {
int firstCard;
int secondCard;
int i;
for (i = 0; i < 100; i++){
firstCard = (rand() % 52);
secondCard = (rand() % 52);
}
}