Skip to content
Snippets Groups Projects
Commit 5d96ff69 authored by Kinadinova Dariya's avatar Kinadinova Dariya
Browse files

repr, compare

parent bce23027
Branches
No related tags found
No related merge requests found
......@@ -70,7 +70,7 @@ class Card(object):
$$$ repr(Card('Ace', 'heart'))
'Card("Ace", "heart")'
"""
return f"(Card("f"{self.value}, "f"{self.color})"
return f'Card("{self.value}", "{self.color}")'
def compare(self, card: Card) -> int:
"""
......@@ -98,7 +98,15 @@ class Card(object):
$$$ c1.compare(c3) == 0
True
"""
...
value1 = Card.VALUES.index(self.value)
value2 = Card.VALUES.index(card.value)
if value1 == value2:
return 0
elif value1 > value2:
return 1
else:
return -1
@staticmethod
def deck(n_card: int) -> list[Card]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment