forked from tiyd-python-2015-01/blackjack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeck.py
30 lines (24 loc) · 786 Bytes
/
deck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import random
from card import Card, ranks, suits
class Deck:
"""A shuffled deck of playing cards.
Responsibilities:
*Constructs a shuffled deck containing 1 of each card.
*Allows cards to be drawn
*Should be able to report it's current size
collaborators:
+Collects 1 of each card from the Card class.
"""
def __init__(self):
self.cards = []
for rank in ranks:
for suit in suits:
card = Card(rank, suit)
self.cards.append(card)
random.shuffle(self.cards)
def __len__(self):
return len(self.cards)
def __str__(self):
return " ".join([card.__str__() for card in self.cards])
def __eq__(self, other):
return self.__cards__ == other.__cards__