// Copyright Sven-Olof Nystrom Uppsala University 2025

import java.util.*;

public class Deck {
    
    private ArrayList<Card> cardSet = new ArrayList<Card>();
    private Random randomGenerator=new Random();
    
    public Deck () {
        for (int s = 0; s<4; s++) {
	    for (int r = 0; r<13; r++) {
		Card c = new Card(s, r);
		cardSet.add(c);
	    }
	}
    }

    public void shuffle() {
        for (int i = 0; i<52; i++) {
            int j = i+randomGenerator.nextInt(52-i);
            swap(i, j);
        }
    }
    
    private void swap(int i, int j) {
        Card t = cardSet.get(i);
        cardSet.set(i, cardSet.get(j));
        cardSet.set(j, t);
    }

    public ArrayList<Card> cardSet() {
        return new ArrayList<Card> (cardSet); //why?
    }
}

