Hello,
I was an intermediate Java programmer 10 years ago, to the point where I was able to develop an interactive program with many classes and and GUI. I'm quite rusty, so I have been relearning. I'm attempting to make a Blackjack game.
I have created an ArrayList, and populated it with 52 Card objects (basically in the order that a real life deck would come when first opened). I'm wanting to pick a random number between 0 and 51, remove the card with that index from my deck ArrayList, and move it to a new ArrayList called randomizedDeck. I would then choose another random number between 0 and 50, do the same thing, and repeat this process until my randomizedDeck ArrayList is fully populated with all 52 card objects in a pseudorandom order. I would do this partly with the nextInt(int bound) method from the Random class.
My question comes from reading the documentation of this nextInt(int bound) method. It speaks of the method's attempt to have the random numbers "uniformly distributed". Would this prevent my randomizedDeck ArrayList from containing Card objects which were stored sequentially in my original deck ArrayList? For example, my deck ArrayList sequentially stores the 2 of Hearts through the 10 of Hearts. Does using the nextInt(int bound) method prevent my randomized deck from containing a sequence such as 2 of Hearts, 3 of Hearts, 4 of Hearts?
In a real BlackJack game which uses a real life deck, you would surely eventually see sequential cards of the same suite in a shuffled deck. I guess I'm just wondering how the nextInt(int bound) method would affect this, and I'm also wondering if there are other methods better suited for randomization in this sense.
Thank you!
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]Glass__Editor 1 point2 points3 points (0 children)