| 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 | public double evaluer() throws NotDigitException { |
| 18 | if(isChiffre()) { |
| 19 | return Character.getNumericValue(c); |
| 20 | } else { |
| 21 | throw new NotDigitException(c + " is not a digit"); |
| 22 | } |
| 23 | } |
| 24 | } |