-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.py
More file actions
59 lines (51 loc) · 2.03 KB
/
Copy pathCard.py
File metadata and controls
59 lines (51 loc) · 2.03 KB
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
55
56
57
58
59
# A Card has a suit and value.
class Card:
# CONSTANTS
# NUM_OF_SUITS (int) the number of possible suits a card could have
# NUM_OF_VALUES (int) the number of possible values a card could have
NUM_OF_SUITS = 4
NUM_OF_VALUES = 13
# CONSTANT LISTS
# SUITS (string[]) contains the suit names
# VALUES (string[]) contains the value names
SUITS = ['Clubs', 'Diamonds', 'Hearts', 'Spades']
VALUES = ['Ace', 'Two', 'Three', 'Four', 'Five', 'Six',
'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King']
# CONSTANT DICTIONARIES
# FILESUITS (string) [key: 'suitName', value: 'the suit char needed to access the gif file']
# FILEVALUES (string) [key: 'valueName', value: 'the value char needed to acces the gif file']
FILESUITS = {SUITS[0]: 'c', SUITS[1]: 'd', SUITS[2]: 'h', SUITS[3]: 's'}
FILEVALUES = {VALUES[0]: '1', VALUES[1]: '2', VALUES[2]: '3', VALUES[3]: '4',
VALUES[4]: '5', VALUES[5]: '6', VALUES[6]: '7', VALUES[7]: '8',
VALUES[8]: '9', VALUES[9]: '10', VALUES[10]: '11', VALUES[11]: '12',
VALUES[12]: '13'}
# IMAGE CONSTANTS
GIF_SIZE_WIDTH = 73
GIF_SIZE_HEIGHT = 97
# Constructs a Card object with a suit and value.
# @param value (string) the value value
# @param suit (string) the suit value
#
def __init__(self, value='', suit=''):
self._value = value
self._suit = suit
## Accessor (Getter)
# @return self._suit (string) the suit of the card
#
def getSuit(self):
return self._suit
## Accessor (Getter)
# @return self._value (string) the value of the card
#
def getValue(self):
return self._value
## Accessor (Getter)
# @return the numeric value of self._value
#
def getNumericValue(self):
return int(Card.FILEVALUES[self._value])
# Prints the string value and suit of the Card
# @return example: 'Ace of Hearts'
#
def __repr__(self):
return self._value + ' of ' + self._suit