From 0224c1a7463d47c2a48382c70bbaf8b52742ddd8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 13 Apr 2018 12:22:17 +0200 Subject: [PATCH] exo6: add the basic operations code. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- exo6/Opadd.java | 6 ++++++ exo6/Opdiv.java | 6 +++++- exo6/Opminus.java | 6 +++++- exo6/Opmul.java | 7 +++++++ exo6/Opmulti.java | 6 +++++- exo6/Opplus.java | 6 +++++- 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/exo6/Opadd.java b/exo6/Opadd.java index 81b3bda..d631090 100644 --- a/exo6/Opadd.java +++ b/exo6/Opadd.java @@ -1,4 +1,10 @@ abstract class Opadd extends Expression { + protected Terme gauche; + protected Expression droite; + Opadd(Terme g, Expression d) { + gauche = g; + droite = d; + } } diff --git a/exo6/Opdiv.java b/exo6/Opdiv.java index 99a3883..0fe9718 100644 --- a/exo6/Opdiv.java +++ b/exo6/Opdiv.java @@ -1,7 +1,11 @@ class Opdiv extends Opmul { + Opdiv(Facteur g,Terme d) { + super(g, d); + } + public double evaluer() { - return 0.0; + return gauche.evaluer() / droite.evaluer(); } } diff --git a/exo6/Opminus.java b/exo6/Opminus.java index d33cd17..9e5307a 100644 --- a/exo6/Opminus.java +++ b/exo6/Opminus.java @@ -1,7 +1,11 @@ class Opminus extends Opadd { + Opminus(Terme g, Expression d) { + super(g, d); + } + public double evaluer() { - return 0.0; + return gauche.evaluer() - droite.evaluer(); } } diff --git a/exo6/Opmul.java b/exo6/Opmul.java index 736b4ef..2793bab 100644 --- a/exo6/Opmul.java +++ b/exo6/Opmul.java @@ -1,4 +1,11 @@ abstract class Opmul extends Terme { + protected Facteur gauche; + protected Terme droite; + + Opmul(Facteur g, Terme d) { + gauche = g; + droite = d; + } } diff --git a/exo6/Opmulti.java b/exo6/Opmulti.java index 596015f..fdb93fd 100644 --- a/exo6/Opmulti.java +++ b/exo6/Opmulti.java @@ -1,7 +1,11 @@ class Opmulti extends Opmul { + Opmulti(Facteur g,Terme d) { + super(g, d); + } + public double evaluer() { - return 0.0; + return gauche.evaluer() * droite.evaluer(); } } diff --git a/exo6/Opplus.java b/exo6/Opplus.java index 0bd4bfa..95b200b 100644 --- a/exo6/Opplus.java +++ b/exo6/Opplus.java @@ -1,7 +1,11 @@ class Opplus extends Opadd { + Opplus(Terme g, Expression d) { + super(g, d); + } + public double evaluer() { - return 0.0; + return gauche.evaluer() + droite.evaluer(); } } -- 2.34.1