From 9c05ac849c54908697b4ed86f68b6255a038bf47 Mon Sep 17 00:00:00 2001 From: Belfadel Mohamed <mohamed.belfadel.etu@118p2.fil.univ-lille.fr> Date: Wed, 27 Mar 2024 09:37:38 +0100 Subject: [PATCH] str --- TP9/card.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/TP9/card.py b/TP9/card.py index 8732779..8203637 100755 --- a/TP9/card.py +++ b/TP9/card.py @@ -71,6 +71,16 @@ class Card(object): 'Card("Ace", "heart")' """ return f"Card(\"{self.value}\", \"{self.color}\")" + + def __str__(self) -> str: + """ + return a string representation of the card + + $$$ repr(Card('Ace', 'heart')) + 'Card("Ace", "heart")' + "Ace of heart" + """ + return f"{self.value} of {self.color}" def compare(self, card: Card) -> int: """ @@ -124,7 +134,7 @@ class Card(object): $$$ len(set(cartes)) len(cartes) """ - ... + def __eq__(self, card: Card) -> bool: """ -- GitLab