diff --git a/Tp08/card.py b/Tp08/card.py index 8e20fc23001cea98f2facbe3dbc57ff8c9c1f4e1..30af6d7250b58b9474c06dab18816af83ece1aeb 100755 --- a/Tp08/card.py +++ b/Tp08/card.py @@ -148,42 +148,62 @@ class Card(object): return True if self equals card False otherwise """ - ... + return (self.value == card.value) and (self.color == card.color) def __neq__(self, card: Card) -> bool: """ return True if self don't equal card False otherwise """ - ... + return (self.value != card.value) and (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 + def __le__(self, card: Card) -> bool: """ return True if self is inferior or equal to card False otherwise """ - ... + return self.value <= card.value + def __gt__(self, card: Card) -> bool: """ 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 def __ge__(self, card: Card) -> bool: """ return True if self is superior or equal to card False otherwise """ - ... + return self.value >= card.value if (__name__ == '__main__'): diff --git a/Tp08/war.py b/Tp08/war.py index fa3c4a2abac46cf552611581dc4c2683cd05c673..c2020bb5ad80dcfd793f9e0776d7ea2e80f6c7d3 100755 --- a/Tp08/war.py +++ b/Tp08/war.py @@ -62,7 +62,9 @@ def gather_stack(main: ApQueue, pile: ApStack) -> None: $$$ all( main.dequeue() == cartes[ 3 - i ] for i in range(3)) True """ - + while not pile.is_empty(): + main.enqueue(pile.pop()) + return main def play_one_round(m1: ApQueue, m2: ApQueue, pile: ApStack) -> None: """