import java.util.ArrayList; import java.util.Collections; public class Deck { private ArrayList cards; public Deck() { cards = new ArrayList<>(); for (int i = 0; i < Suit.values().length; i++) for (int j = 0; j < Rank.values().length; j++) { if (Suit.values()[i].equals(Suit.HEARTS) && Rank.values()[j].equals(Rank.QUEEN)) continue; // Skip the Queen of Hearts cards.add(new Card(Suit.values()[i], Rank.values()[j])); } } public ArrayList getCards() { return cards; } /* * IMPORTANT: When asked to perform a sort, shuffle (or the like) in a lab, * assignment, mid-term or the final exam, you are supposed to provide your own * implementation, similar to what Q4 in part1 and Game in part2 do for sort. * Unless you have been specifically instructed otherwise, you are NOT allowed to use * methods such as Collections.shuffle(), like the method below does for * simplicity. */ public void shuffle() { Collections.shuffle(cards); } }