From 5d96ff6930414d4f83931217c7afb526b01f9181 Mon Sep 17 00:00:00 2001
From: Kinadinova Dariya <dariya.kinadinova.etu@118p27.fil.univ-lille.fr>
Date: Wed, 27 Mar 2024 09:53:03 +0100
Subject: [PATCH] repr, compare

---
 tp8/bataille-carte/card.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tp8/bataille-carte/card.py b/tp8/bataille-carte/card.py
index 04c1532..6727938 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]:
-- 
GitLab