

package jcrib;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Deck {

    protected List<Card> cards = new ArrayList<>();

    public Deck(boolean standardDeck) {
        if (standardDeck) {
            cards.clear();
            for (Suit suit : Suit.values()) {
                for (int i = 1; i <= 10; ++i) {
                    addCard(new Card(i, suit));
                }

                for (Face face : Face.values()) {
                    addCard(new Card(face, suit));
                }
            }
        }
    }

    public Deck() {
        this(true);
    }

    public void addCard(Card card) {
        cards.add(card);
    }

    public Card removeCard(int index) {
        return cards.remove(index);
    }

    public boolean removeCard(Card card) {
        return cards.remove(card);
    }

    public Card getCard() {
        return cards.get(0);
    }

    public Card getCard(int index) {
        return cards.get(index);
    }

    public List<Card> getCards() {
        return cards;
    }

    public void deal(int numCards, Player... players) {
        deal(numCards, players);
    }

    public void deal(int numCards, Iterable<Player> players) {
        for (int i = 0; i < numCards; ++i) {
            for (Player player : players) {
                Card card = cards.remove(0);
                player.getHand().addCard(card);
            }
        }
    }

    public void shuffle() {
        int idx;
        Card temp, current;
        Random random = new Random();
        for (int i = cards.size() - 1; i > 0; i--) {
            idx = random.nextInt(i + 1);
            current = cards.get(i);
            temp = cards.get(idx);

            /* Swap the two cards */
            cards.set(idx, current);
            cards.set(i, temp);
         }
    }

    public int numCards() {
        return cards.size();
    }

    public String toString() {
        String str = "";
        for (Card card : cards) {
            str += card + ", ";
        }
        return str;
    }
}

@@ -676,32 +676,102 @@
 d(card);%0A    %7D%0A%0A
+    public Card removeCard() %7B%0A        return cards.remove(0);%0A    %7D%0A%0A
     public Card 
@@ -786,32 +786,32 @@
 rd(int index) %7B%0A
-
         return c
@@ -1055,32 +1055,112 @@
 (index);%0A    %7D%0A%0A
+    public int getIndex(Card card) %7B%0A        return cards.indexOf(card);%0A    %7D%0A%0A
     public List%3C
@@ -1571,32 +1571,110 @@
        %7D%0A    %7D%0A%0A
+    /**%0A     * Performs a Fisher%E2%80%93Yates shuffle on the deck, in place.%0A     */%0A
     public void 
@@ -2078,32 +2078,32 @@
 nt numCards() %7B%0A
-
         return c
@@ -2114,32 +2114,127 @@
 .size();%0A    %7D%0A%0A
+    public Card%5B%5D toCardArray() %7B%0A        return cards.toArray(new Card%5Bcards.size()%5D);%0A    %7D%0A%0A
     public Strin

Add deck functions: