my task is Design and implement an abstract base class ArithmeticExpression that represent any
binary (having two arguments) arithmetic expression. The abstract class should include at least
two methods called evaluate and display....
i have done the code but it doesnt output anything.. im really stuck.. does anyone know why? please help. urgent
/**
* Class representing a binary Arithmetic Expression.
*
*/
public abstract class ArithmeticExpression {
//
// Arithmetic expression given as first operand
protected ArithmeticExpression ae1;
//
// Arithmetic expression given as second operand
protected ArithmeticExpression ae2;
//
// First operand
protected double operand1;
//
// Second operand
protected double operand2;
/**
* Evaluates the arithmetic expression that the object represents.
* @return result of the expression.
*/
public abstract double evaluate();
/**
* Returns the raw expression
*/
public void display() {
System.out.println(toString());
}
@Override
public String toString() {
String result = "(" ;
if (ae1 != null) {
//
// First operand is an expression!
result += ae1;
} else {
// Normal operand
result += operand1;
}
// Form the complete string.
result += ")" + getSymbol() + "(";
if (ae2 != null) {
//
// Second operand is an expression!
result += ae2;
} else {
// Normal operand
result += operand2;
}
result += ")";
return result;
}
/**
* Get the operation symbol.
* @return symbol
*/
public abstract String getSymbol();
}