I\'m trying to do the Fisher Yates shuffle on a list of Cards. I\'ve scoured forums and the only implementation of Fisher Yates is with normal int arrays like below
Having actually done this before (albeit using my own shuffle, still based on ints), I would do this:
Add a constructor to the card class that takes an int
. Its pretty easy to map the 52 cards of a deck to the numbers 0-51, so I'll leave that to you. Note: This becomes a lot easier if you map the suits to 0-3, instead of the seemingly random numbers you have chosen.
Create a starting "deck" using a for loop to generate all 52 cards.
Run the shuffle on this created list.