-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTable.py
54 lines (44 loc) · 1.32 KB
/
Table.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Table:
'''
This class represents a Table object. A Table has cards
that are currently in play.
'''
def __init__(self):
'''
Sets the cards_on_table
Attributes:
cards_on_table (list): the cards value
'''
self.cards_on_table = []
def get_cards_on_table(self):
'''
Gets the cards currently on table
Parameter:
cards_on_table (list): the cards currently on table
'''
return self.get_cards_on_table
def set_cards_on_table(self, cards_on_table):
'''
Sets the cards on the table
Parameter:
cards_on_table (list): the cards to be set on table
'''
self.cards_on_table = cards_on_table
def clear_table(self, deck):
'''
Clears the table
Parameters:
deck (Deck): the deck currently in use on the table
'''
cards = deck.get_cards_in_deck()
cards.extend(deck.get_cards_not_in_deck())
deck.set_cards_in_deck(cards)
deck.set_cards_not_in_deck([])
deck.shuffle()
def __str__(self):
'''
Returns string representation of cards_on_table
Returns:
(str): string of cards_on_table
'''
return 'Cards on table: ' + str(self.cards_on_table)