From 90c39fdf9265f875ba2409619a44a244dda50fe3 Mon Sep 17 00:00:00 2001 From: Belfadel Mohamed <mohamed.belfadel.etu@118p2.fil.univ-lille.fr> Date: Wed, 3 Apr 2024 11:15:50 +0200 Subject: [PATCH] gather_stack --- TP9/card.py | 2 +- TP9/war.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/TP9/card.py b/TP9/card.py index b6f4739..d0b25f6 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 7ceee82..8571f65 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: """ -- GitLab