/**
* Informatik II - FS2009
* Uebungsserie 4, Aufgabe 2
*
* ...ADD YOUR COMMENTS HERE...
*/
public class Expr {
char[] input;
public Expr(char[] c) {
input = c;
}
/**
* "...ADD YOUR COMMENTS HERE..."
*/
public int evalExpr() {
//evaluate expression starting from index 0
return this.evalExprRec( 0 );
}
/**
* "...ADD YOUR COMMENTS HERE..."
*/
public int evalExprRec(int i) {
if (!Character.isDigit( input[i] )) {
System.out.println("Error .... ");
System.exit( 1 );
}
// stop condition?
// syntax check?
// recursive call?
// return value?
return -1; // this return instruction is here only as a placeholder!!
}
public static void main( String[] args ) {
if( args.length != 1) {
System.out.println("Please enter a correct input!");
System.out.println("Example: java Expr \"1*2*3*4\"" );
System.exit( 1 );
}
Expr expression = new Expr(args[0].toCharArray());
int result = expression.evalExpr();
System.out.println( "The evaluation of "
+ args[0] +
" gives: " + result );
}
}