diff --git a/Tp08/card.py b/Tp08/card.py index 30af6d7250b58b9474c06dab18816af83ece1aeb..90311562689ff648490a8dbe242f950cd7db738c 100755 --- a/Tp08/card.py +++ b/Tp08/card.py @@ -155,23 +155,14 @@ class Card(object): return True if self don't equal card False otherwise """ - return (self.value != card.value) and (self.color != card.color) + return (self.value != card.value) or (self.color != card.color) def __lt__(self, card: Card) -> bool: """ return True if self is strictly inferior to card False otherwise """ - if self.value < card.value: - res = True - elif self.value == card.value: - if self.color < card.color: - res = True - else: - res = False - else: - res = False - return res + return self.compare(card) == -1 def __le__(self, card: Card) -> bool: @@ -179,7 +170,7 @@ class Card(object): return True if self is inferior or equal to card False otherwise """ - return self.value <= card.value + return self.compare(card) <= 0 def __gt__(self, card: Card) -> bool: @@ -187,23 +178,14 @@ class Card(object): return True if self is strictly superior to card False otherwise """ - if self.value > card.value: - res = True - elif self.value == card.value: - if self.color > card.color: - res = True - else: - res = False - else: - res = False - return res + return self.compare(card) == 1 def __ge__(self, card: Card) -> bool: """ return True if self is superior or equal to card False otherwise """ - return self.value >= card.value + return self.compare(card) >= 0 if (__name__ == '__main__'): diff --git a/Tp08/war.py b/Tp08/war.py index c2020bb5ad80dcfd793f9e0776d7ea2e80f6c7d3..d7173bda3d55ef363769385a90189b45bef4d620 100755 --- a/Tp08/war.py +++ b/Tp08/war.py @@ -81,7 +81,7 @@ def play_one_round(m1: ApQueue, m2: ApQueue, pile: ApStack) -> None: precondition : m1 et m2 ne sont pas vides """ - ... + def play(n_card: int, n_round: int) -> None: """