-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.py
More file actions
50 lines (39 loc) · 1.07 KB
/
Card.py
File metadata and controls
50 lines (39 loc) · 1.07 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
from random import shuffle
class Card:
suits=["Hearts","Diamonds","Clubs","Spades"]
values=["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
def __init__(self,suit,value):
self.suit=suit
self.value=value
def __repr__(self):
return f"{self.value} of {self.suit}"
class Deck:
total_cards=52
def __init__(self):
for suit in suits:
for val in values:
deck_of_cards=Card(suit,val)
def __rep__(self):
return f"Deck of {amount} cards"
def _deal(self,num):
if self.count() > 0:
if self.count>=num:
total_cards-=num
deck_of_cards[num:]
return deck_of_cards[:-num]
else:
deck_of_cards[:-self.count()]
return deck_of_cards[:-num]
else:
return ValueError ("Only full deck can be shuffled")
def count(self):
return total_cards
def shuffle(self):
if self.count()==52:
return shuffle(deck_of_cards)
else:
return ValueErro ("Only full deck can be shuffeled")
def deal_card(self,1):
return self._deal(1)
def deal_hand(self,num):
return self._deal(num)