diff --git a/TP9/card.py b/TP9/card.py index b6f473922e6076fbeb0ba2e7bf0423da74bb484e..d0b25f6a06e39f12ece8b35501f8dcaece47b43a 100755 --- a/TP9/card.py +++ b/TP9/card.py @@ -149,7 +149,7 @@ 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: """ diff --git a/TP9/war.py b/TP9/war.py index 7ceee8298d7981f41147c055698485423246fc2f..8571f65fd1b10b098d1df0307a843d62e682107d 100755 --- a/TP9/war.py +++ b/TP9/war.py @@ -59,15 +59,16 @@ def gather_stack(main: ApQueue, pile: ApStack) -> None: $$$ cartes = Card.deck(4) $$$ main = ApQueue() $$$ pile = ApStack() - $$$ for c in cartes: - pile.push(c) + $$$ for c in cartes: pile.push(c) $$$ gather_stack( main, pile ) $$$ len( main ) == 4 True $$$ 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: """