X-Git-Url: https://git.piment-noir.org/?p=Project_POO.git;a=blobdiff_plain;f=exo6%2FVariable.java;h=30b7830a2b239517fcd0041c973229fe40c304ae;hp=d023c985b72183324cc6fb1e37e342c78c3d535c;hb=c9ca22835b3ec5dd779b4e8ffae46ceb829d4b1a;hpb=dd8febe84e80f37113dd364315ec5688e220c012 diff --git a/exo6/Variable.java b/exo6/Variable.java index d023c98..30b7830 100644 --- a/exo6/Variable.java +++ b/exo6/Variable.java @@ -1,7 +1,24 @@ +import java.util.TreeMap; class Variable extends Terme { + TreeMap v; - public boolean evaluer() { - return true; + Variable(Character c) throws NotCharacterException { + v = new TreeMap(); + //TODO?: remove extragenous whitespace + if (Character.isLetterOrDigit(c)) { + v.put(c, 0.0); // we suppose the default variable value is 0 + } else { + throw new NotCharacterException(c + " is not a character type"); + } + } + + private boolean isVariable() { + //FIXME: this cover more than latin alphabet + return Character.isLetter(v.firstKey()); + } + + public double evaluer() { + return 0.0; } }