-
-
Save amankharwal/b34e899b84021237217cb5085c499802 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Card: | |
suits = ["spades", | |
"hearts", | |
"diamonds", | |
"clubs"] | |
values = [None, None,"2", "3", | |
"4", "5", "6", "7", | |
"8", "9", "10", | |
"Jack", "Queen", | |
"King", "Ace"] | |
def __init__(self, v, s): | |
"""suit + value are ints""" | |
self.value = v | |
self.suit = s | |
def __lt__(self, c2): | |
if self.value < c2.value: | |
return True | |
if self.value == c2.value: | |
if self.suit < c2.suit: | |
return True | |
else: | |
return False | |
return False | |
def __gt__(self, c2): | |
if self.value > c2.value: | |
return True | |
if self.value == c2.value: | |
if self.suit > c2.suit: | |
return True | |
else: | |
return False | |
return False | |
def __repr__(self): | |
v = self.values[self.value] +\ | |
" of " + \ | |
self.suits[self.suit] | |
return v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment