From 9ee2b27a389570382f979ba560f4855dd261a13e Mon Sep 17 00:00:00 2001 From: Louis Chmielewski <louis.chmielewski@icloud.com> Date: Wed, 27 Mar 2024 09:35:33 +0100 Subject: [PATCH] __str__ class Card --- Tp08/card.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Tp08/card.py b/Tp08/card.py index df725a8..b0e103d 100755 --- a/Tp08/card.py +++ b/Tp08/card.py @@ -72,6 +72,15 @@ class Card(object): """ return f"Card(\"{self.value}\", \"{self.color}\")" + def __str__(self) -> str: + """ + return a string representation of the card + + $$$ str(Card('Ace', 'heart')) + "Ace of heart" + """ + return f"{self.value} of {self.color}" + def compare(self, card: Card) -> int: """ compares cards. @@ -124,6 +133,8 @@ class Card(object): len(cartes) """ ... + + def __eq__(self, card: Card) -> bool: """ -- GitLab