X-Git-Url: https://git.piment-noir.org/?p=Project_POO.git;a=blobdiff_plain;f=exo6%2FVariable.java;h=6a85fbbc94704a433136a32fb021525fb05eb3b8;hp=d023c985b72183324cc6fb1e37e342c78c3d535c;hb=bd83b176f508492a46cc4f76998721c30a22d291;hpb=dd8febe84e80f37113dd364315ec5688e220c012 diff --git a/exo6/Variable.java b/exo6/Variable.java index d023c98..6a85fbb 100644 --- a/exo6/Variable.java +++ b/exo6/Variable.java @@ -1,7 +1,38 @@ +import java.util.TreeMap; +import java.util.Map.Entry; class Variable extends Terme { + //TODO: TreeMap might look overkill + TreeMap v; - public boolean evaluer() { - return true; + Variable() { + v = new TreeMap(); + fill(-5.0, 5.0, 0.25); + } + + /** + * Fill the variable with a discret set of double values + * @param start starting double value + * @param end ending double value + * @param step looping step + */ + private void fill(double start, double end, double step) { + int i = 0; + for (double d = start; d <= end; d = d + step) { + v.put(i, d); + i++; + } + } + + public Entry getFirstEntry() { + return v.firstEntry(); + } + + public Integer size() { + return v.size(); + } + + public double evaluer() { + return v.pollFirstEntry().getValue(); } }