Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Deck(list):
- def __init__(self):
- super(Deck, self).__init__()
- for val in range(2,15):
- for suit in 'CSHD':
- self.append(Card(val, suit))
- random.shuffle(self)
- class Card(object):
- def __init__(self, val, suit):
- self.val = val
- self.suit = suit
- def __str__(self):
- vals = map(str, range(2,11))+list('JQKA')
- suits = {'H': 'Hearts', 'S': 'Spades', 'D': 'Diamongs', 'C': 'Clubs'}
- return '%s of %s' % (vals[self.val-2], suits[self.suit])
- def __cmp__(self, object):
- return cmp(self.val, object.val)
- def __repr__(self):
- return str(self)
Advertisement
Add Comment
Please, Sign In to add comment