I'm writing a method to shuffle a deck and am unsure if it's executing properly. I'm not sure how to check if it is shuffling 1000 times. (using constant public static final int TIMES_TO_SHUFFLE = 1000) My instructions are in the javadoc before the code. I tried using the debugger but I kept looping in the block and am unsure how to properly use it. Here is my code...
It looks like your instructions for the assignment are in the javadoc....
So, with that in mind, your shuffle method looks like it will do some shuffling, but it is not doing what the javadoc says it should. You are looping through the entire deck TIMES_TO_SHUFFLE times vice doing that many "swaps" within the deck. Hopefully that's clear and gives you some direction on where you need to tweak your code.
After you think you are close, you can put a println statement in there to compare the deck before and after a "shuffle" is called to convince yourself something is happening.
(Consider using loop(s) in loadDeck rather than specifying each card manually, which is rather error-prone.)
Note also that "shuffling" in code is a different operation than shuffling a physical deck of cards--shuffling 1000 times is not likely to give you a deck that's (substantially?) more random than shuffling once.
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
a bit of art, as a gift, the permaculture playing cards