From: Jérôme Benoit Date: Fri, 13 Apr 2018 10:22:17 +0000 (+0200) Subject: exo6: add the basic operations code. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=0224c1a7463d47c2a48382c70bbaf8b52742ddd8;p=Project_POO.git exo6: add the basic operations code. Signed-off-by: Jérôme Benoit --- 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(); } }