6774f5e9ac9ef5d9c724bedc9b6d64dc6c92b746
[Project_POO.git] / exo6 / Chiffre.java
1
2 class Chiffre extends Facteur {
3 Character c;
4
5 Chiffre(Character c) throws NotCharacterException {
6 //TODO?: remove extragenous whitespace
7 if (Character.isLetterOrDigit(c)) {
8 this.c = c;
9 } else {
10 throw new NotCharacterException(c + " is not a character type");
11 }
12 }
13
14 private boolean isChiffre() {
15 return Character.isDigit(c);
16 }
17
18 public double evaluer() throws NotDigitException {
19 if(isChiffre()) {
20 return Character.getNumericValue(c);
21 } else {
22 throw new NotDigitException(c + " is not a digit");
23 }
24 }
25 }