public int Evaluate() { int value1 = _expr1.Evaluate(); int value2 = _expr2.Evaluate(); return(value1 - value2); }
static void Main(string[] args) { var parser = new Parser(); var commands = new string[] { "+ 5 6", "- 6 5", "+ - 4 5 6", "+ 4 - 5 6", "+ - + - - 2 3 4 + - -5 6 + -7 8 9 10" }; foreach (var command in commands) { ExpressionBase.IExpressionBase expression = parser.Parse(command); Console.WriteLine("{0} = {1}", expression, expression.Evaluate()); } }