Task

Create a data structure and the associated methods to define and manipulate a deck of   playing cards.

The deck should contain 52 unique cards.

The methods must include the ability to:

   make a new deck
   shuffle (randomize) the deck
   deal from the deck
   print the current contents of a deck 
Each card must have a pip value and a suit value which constitute the unique value of the card.

Related tasks:

 Card shuffles
 Deal cards_for_FreeCell
 War Card_Game
 Poker hand_analyser
 Go Fish


suits = ["Spades", "Clubs", "Hearts", "Diamonds"]
pips = ["Ace","Two","Three","Four","Five","Six","Seven",
    "Eight","Nine","Ten","Jack","Queen","King"]
 
Card = {}
Card.str = function()
    return self.pip + " of " + self.suit + " (value: " + self.value + ")"
end function
 
//Build Deck
deck = []
for s in suits.indexes
    for p in pips.indexes
        card = new Card
        card.suit = suits[s]
        card.pip = pips[p]
        card.value = s * 100 + p
        deck.push card
    end for
end for
 
draw = function(count=7)
    hand = []
    for i in range(1, count)
        hand.push deck.pop
    end for
    return hand
end function
 
display = function(stack)
    for card in stack
        print card.str
    end for
end function
 
print "Deck created. Cards in Deck: " + deck.len
 
deck.shuffle
print "Deck Shuffled"
 
hand = draw
print "First hand: "
display hand
 
print
print deck.len + " cards left in deck:"
display deck