I am currently writing a card game in Java. My question is when I write the follwoing code below:

Inline Code Example Here

38    // select a random number between 0 and 51
39    int second = randomNumbers.nextInt( NUMBER_OF_CARDS );

Will the program properly generate 52 cards? Should I be using ( NUMBER_OF_CARDS - 1) equals 52 real cards or would it properly generate the 52 cards the way I have it programmed?

Thanks for all the assistance!



Recommended Answers

All 2 Replies

generate 52 cards? no, it will just assign one value, in the range of 0-51. (assuming that your NUMBER_OF_CARDS variable has the value 52)

Reading the API doc for the method you are using should help you understand what it does. If you have questions about what it says, copy the text of the doc here and ask your questions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.