From f18d3d6d68535eebc04a3d62547c56c6bd175f27 Mon Sep 17 00:00:00 2001 From: Manon Date: Tue, 28 Jan 2025 15:14:15 +0100 Subject: [PATCH] =?UTF-8?q?m=C3=A9thode=20str=20a=20faire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projet_calculatrice.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/projet_calculatrice.py b/projet_calculatrice.py index b9baa2e..0ef9ec7 100644 --- a/projet_calculatrice.py +++ b/projet_calculatrice.py @@ -13,14 +13,23 @@ class Expression : if self.valeur == '*': return multiplication(valeur.gauche, valeur.droit) - if self.valeur == '+': + elif self.valeur == '+': return addition(valeur.gauche, valeur.droit) - else : - pass + def parcours_dfs_infixe(a): + """Affiche tous les nœuds de l'arbre a par un parcours DFS préfixé.""" + if a is None: + return + parcours_dfs_infixe(a.gauche) + print(a.valeur) + parcours_dfs_infixe(a.droit) + - def __str__ : #affichage en dfs infixe + def __str__ (self): #affichage en dfs infixe + for val in self.__file: + s = str(val) + return s def multiplication (valeur.gauche, valeur.droit):