Skip to content
Snippets Groups Projects
Commit 0a30ba44 authored by Almohamed Alsadou Fatima's avatar Almohamed Alsadou Fatima
Browse files

methode compare

parent e740af1a
No related branches found
No related tags found
No related merge requests found
......@@ -67,10 +67,22 @@ class Card(object):
"""
return a string representation of the card
$$$ Card('Ace', 'heart')
Card("Ace", "heart")
$$$ repr(Card('Ace', 'heart'))
'Card("Ace", "heart")'
"""
return f"Card({self.value},{self.color})"
def __str__(self)->str:
"""à_remplacer_par_ce_que_fait_la_fonction
Précondition :
Exemple(s) :
$$$
"""
return f"{self.value}/{self.color}"
def compare(self, card: Card) -> int:
"""
......@@ -98,10 +110,10 @@ class Card(object):
$$$ c1.compare(c3) == 0
True
"""
if Card.VALUES[self.value]>Card.Value[card.value]:
if self.value>card.value:
res=1
elif Card.VALUES[self.value]<Card.Values[card.value]:
elif self.value<card.value:
res=-1
else:
res=0
......@@ -123,8 +135,11 @@ class Card(object):
$$$ len(set(cartes))
len(cartes)
"""
...
res=[]
for i in range(n_card):
res.append(random.choice(cartes))
return res
def __eq__(self, card: Card) -> bool:
"""
return True if self equals card
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment