Hey, I am not stuck on this or anything just a bit confused about if this is the right way to go..

Well i was wondering on the river (five cards that go into the middle of the table) i am going to make them random and that is no problem just the way i am thinking of is quite long..

Would doing something like this be ok? (In ok i mean is it one of the best, If not please correct)

riverCard1 = rand();

if(riverCard1 == 1) cout << "Ace Of Hearts" << " ";
else if(riverCard1 == 2) cout << "1 Of Hearts" << " ";

// .. etc etc etc
9 Years
Discussion Span
Last Post by Salem

Yes. You'd need to limit rand to the amount of cards in a deck.
You'd typically use a switch statement instead of the if/else's there. You'll need a for loop to check if the card has already been drawn.
Btw, the river is the fifth card dealt not the name for all 5.


To make rand() generate a random number inbetween a certain value you need to do something like this:

int var = rand() % 100; // Generates a random number between 0 and 100

But every time you load the program up you should first call srand(time(NULL));


A class called 'card', which knows about suit and rank.
A class called 'deck', with 52 cards in it.

'deck' has methods like 'shuffle' and 'draw'.

Call shuffle, then a loop to call draw 5 times.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.