exo6: add constructor and some sanity checks to Chiffre and Variable
[Project_POO.git] / exo6 / Variable.java
1 import java.util.TreeMap;
2
3 class Variable extends Terme {
4 TreeMap<Character, Double> v;
5
6 Variable(Character c) throws NotCharacterException {
7 v = new TreeMap<Character, Double>();
8 //TODO?: remove extragenous whitespace
9 if (Character.isLetterOrDigit(c)) {
10 v.put(c, 0.0); // we suppose the default variable value is 0
11 } else {
12 throw new NotCharacterException(c + " is not a character type");
13 }
14 }
15
16 private boolean isVariable() {
17 //FIXME: this cover more than latin alphabet
18 return Character.isLetter(v.firstKey());
19 }
20
21 public double evaluer() {
22 return 0.0;
23 }
24 }