Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Deck {
- ArrayList<Card> deck;
- public static void suffleSystem(ArrayList<Card> deck)
- {
- Collections.shuffle(deck);
- }
- // TODO not forget seed it somewhere
- static Random random = new Random();
- public static void suffleManual(ArrayList<Card> deck)
- {
- int size = deck.size();
- for (int idx = 0; idx<deck.size(); idx++)
- {
- int chgIdx = idx + random.nextInt(size-idx);
- // swap here
- Card temp = deck.get(idx);
- deck.set(idx, deck.get(chgIdx));
- deck.set(chgIdx, temp);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement