/**
 *
 */
package com.github.apixandru.games.rummikub.model;

import java.util.Collections;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @author Alexandru-Constantin Bledea
 * @since Sep 20, 2015
 */
public final class CardPile {

    private final Queue<Card> cards;

    {
        final LinkedList<Card> cards = new LinkedList<Card>();

        for (final Rank rank : Rank.values()) {
            for (final Color color : Color.values()) {
                cards.add(new Card(color, rank));
            }
        }

        // jokers
        cards.add(new Card(null, null));
        cards.add(new Card(null, null));

        Collections.shuffle(cards);

        this.cards = cards;
    }

    /**
     * @return
     */
    public int getNumberOfCards() {
        return this.cards.size();
    }

    /**
     * @return
     */
    public boolean hasMoreCards() {
        return !this.cards.isEmpty();
    }

    /**
     * @return
     */
    public Card nextCard() {
        return this.cards.remove();
    }

}

@@ -345,24 +345,66 @@
 t%3CCard%3E();%0A%0A
+        for (int i = 0; i %3C 2; i++) %7B%0A    
         for 
@@ -443,32 +443,36 @@
 ) %7B%0A            
+   
+ 
 for (final Color
@@ -506,32 +506,36 @@
                 
+    
 cards.add(new Ca
@@ -568,18 +568,24 @@
     
+ 
-%7D%0A
+   %7D%0A  
         
 %7D%0A%0A 
@@ -576,27 +576,32 @@
 %7D%0A          
-%7D%0A%0A
+  %7D%0A    
         // j
@@ -608,10 +608,13 @@
 oker
-s
 %0A
+    
     
@@ -662,40 +662,9 @@
     
-cards.add(new Card(null, null));
+%7D
 %0A%0A  

generate two sets of cards