-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpartB-q1.py
More file actions
35 lines (27 loc) · 841 Bytes
/
partB-q1.py
File metadata and controls
35 lines (27 loc) · 841 Bytes
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
import random
class Card:
def __init__(self, rank, suit):
self._suit = suit
self._rank = rank
def getSuit(self):
return self._suit
def printCard(self):
print(self._rank,"of",self._suit)
def getRank(self):
return self._rank
def shuffle(self):
ranks = ["Ace","King","Queen","Jack","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten"]
suits = ["Diamond","Club","Spade","Heart"]
self._rank = ranks[random.randint(0,12)]
self._suit = suits[random.randint(0,3)]
def cheat(self,rank, suit):
self._rank = rank
self_suit = suit
c = Card("Ace","Spade")
print(c.getRank())
print(c.getSuit())
c.printCard()
c.shuffle()
c.printCard()
c.cheat("King", "Heart")
c.printCard()