diff --git a/tp8/bataille-carte/card.py b/tp8/bataille-carte/card.py index 04c1532f95d2f3f75c6270c5fc844ccf7156faeb..67279389d8cccdabdb8859feeb7ecba068b58056 100755 --- a/tp8/bataille-carte/card.py +++ b/tp8/bataille-carte/card.py @@ -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]: