import java.util.*;

/*
 * Represents a single deck of cards. Initially the deck
 * is empty until populated.
 */

public class Deck
{
    public static final int SIZE_OF_SPACE_CARDS_DECK = 10007;

    public Deck ()
    {
        this(SIZE_OF_SPACE_CARDS_DECK, false);
    }

    public Deck (int deckSize, boolean debug)
    {
        _theDeck = new Vector<Integer>(deckSize);
        _debug = debug;

        initialise();
    }

    public final void populateWithCards ()
    {
        for (int i = 0; i < _theDeck.capacity(); i++)
        {
            _theDeck.set(i, i);
        }
    }

    public boolean dealInto (Deck recipient)
    {
        if (_theDeck.size() != recipient._theDeck.size())
            return false;

        for (int i = 0; i < _theDeck.capacity(); i++)
        {
            recipient._theDeck.set(_theDeck.capacity() -1 -i, _theDeck.elementAt(i));
        }

        return true;
    }

    public boolean cut (int numberOfCards)
    {
        if (numberOfCards < 0)
            return false; // for now!

        if (numberOfCards > _theDeck.size())
            return false;
        
        if (numberOfCards < _theDeck.size())
        {
            Vector<Integer> cutDeck = new Vector<Integer>(_theDeck.size());

            for (int i = 0; i < _theDeck.size() - numberOfCards; i++)
                cutDeck.add(i, _theDeck.elementAt(numberOfCards + i));

            for (int j = 0; j < numberOfCards; j++)
                cutDeck.add(_theDeck.size() - numberOfCards + j, _theDeck.elementAt(j));

            _theDeck = cutDeck;
        }

        return true;
    }

    public String toString ()
    {
        String str = "Deck: ";

        for (int i = 0; i < _theDeck.size(); i++)
            str += " "+_theDeck.elementAt(i);

        return str;
    }

    private void initialise ()
    {
        for (int i = 0; i < _theDeck.capacity(); i++)
            _theDeck.add(-1);
    }

    private Vector<Integer> _theDeck;
    private boolean _debug;
}
@@ -468,16 +468,52 @@
 Cards ()
+  // resets if called multiple times
 %0A    %7B%0A 
@@ -1024,17 +1024,18 @@
 OfCards 
-%3C
+!=
  0)%0A    
@@ -1042,66 +1042,396 @@
     
-    return false; // for now!%0A%0A        if (numberOfCards %3E
+%7B%0A            if (Math.abs(numberOfCards) %3E _theDeck.size())%0A                return false;%0A            %0A            if (numberOfCards %3E 0)%0A                cutPositive(numberOfCards);%0A            else%0A                cutNegative(Math.abs(numberOfCards));%0A        %7D%0A%0A        return true;%0A    %7D%0A%0A    public String toString ()%0A    %7B%0A        String str = %22Deck: %22;%0A%0A        for (int i = 0; i %3C
  _th
@@ -1434,32 +1434,37 @@
  _theDeck.size()
+; i++
 )%0A            re
@@ -1461,35 +1461,132 @@
         
-return false;
+str += %22 %22+_theDeck.elementAt(i);%0A%0A        return str;%0A    %7D%0A%0A    private void cutPositive (int numberOfCards)
 %0A    
- 
+%7B
    %0A    
@@ -2043,105 +2043,206 @@
   %7D%0A
-%0A
     
+%7D%0A%0A
     
-return true;%0A    %7D%0A%0A    public String toString ()%0A    %7B%0A        String str = %22Deck: %22;%0A%0A
+private void cutNegative (int numberOfCards)%0A    %7B%0A        if (numberOfCards %3C _theDeck.size())%0A        %7B%0A            Vector%3CInteger%3E cutDeck = new Vector%3CInteger%3E(_theDeck.size());%0A%0A    
     
@@ -2272,32 +2272,48 @@
  _theDeck.size()
+ - numberOfCards
 ; i++)%0A         
@@ -2311,35 +2311,43 @@
             
-str += %22 %22+
+    cutDeck.add(i, 
 _theDeck.ele
@@ -2345,33 +2345,50 @@
 eDeck.elementAt(
-i
+numberOfCards + i)
 );%0A%0A        retu
@@ -2379,35 +2379,199 @@
 );%0A%0A        
+   
-return str;
+ for (int j = 0; j %3C numberOfCards; j++)%0A                cutDeck.add(_theDeck.size() - numberOfCards + j, _theDeck.elementAt(j));%0A%0A            _theDeck = cutDeck;%0A        %7D
 %0A    %7D%0A%0A    

Update Deck.java