-
Notifications
You must be signed in to change notification settings - Fork 1
/
deck.py
37 lines (30 loc) Β· 798 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
31
32
33
34
35
36
37
#!/usr/bin/env python3
import random
from card import Card
class Deck:
def __init__(self):
self.cards = []
def fillDeck(self):
"""
fillDeck(): creates a standard 52-card Deck
"""
self.cards = []
for suit in range(4):
for val in range(1, 14):
self.cards.append(Card(suit, val))
def addCard(self, newCard):
"""
addCard(): appends a Card to the deck
"""
self.cards.append(newCard)
def shuffle(self):
"""
shuffle(): randomly shuffles the deck
"""
random.shuffle(self.cards)
def drawCard(self):
"""
drawCard(): returns and removes the top card of the deck
"""
card = self.cards.pop()
return card