# This module contains 2 classes.
#
# Class Card represents a single playing card.
# cards have attributes suit, rank and value.
# Class Card has 2 methods: __lt__( ) and __str__()
#
# Class Deck maintains a list of cards, initially 52.
# It has 2 methods: deal(self, n), which returns a list
# of n cards (which are then removed from the deck), and
# shuffle( ), which randomizes the deck.

import random
class Card:
    def __init__(self, suit, rank, value):
        self.suit = suit
        self.rank = rank
        self.value = value

    def __lt__(self, other):
        if self.value < other.value:
            return True
        else:
            return False

    def __str__(self):
        return "%s of %s"%(self.rank, self.suit)

class Deck:
    def __init__(self):
        self.cards = []
        for suit in ["Spades", "Hearts", "Diamonds", "Clubs"]:
            for r in range(2, 11):
                card =  Card(suit, str(r), r)
                self.cards.append(card)
            self.cards.append( Card(suit, "Jack", 11))
            self.cards.append( Card(suit, "Queen", 12))
            self.cards.append( Card(suit, "King", 13))
            self.cards.append( Card(suit, "Ace", 14))

    def deal(self, n):
        hand = self.cards[0:n]
        self.cards = self.cards[n:]
        return hand

    def shuffle(self):
        list = []
        while len(self.cards) > 0:
            i = random.randint(0, len(self.cards)-1)
            list.append(self.cards[i])
            del self.cards[i]
        self.cards = list
        
def main():
    D = Deck()
    D.shuffle()
#    hand = D.deal(5)
#    hand2 = D.deal(5)
    for x in D.cards:
        print(x)
#    print("*****")
#    for x in hand2:
#        print(x)

main()
                                   













    
        

