public override int Evaluate(EvaluateOption option, Calculator calculator) { VerifyEvaluationState(); int result = 0; switch (option) { case EvaluateOption.UIEvaluate: calculator.Clear(); int leftValue = Left.Evaluate(option, calculator); calculator.Clear(); int rightValue = Right.Evaluate(option, calculator); calculator.Clear(); calculator.Result = leftValue; InvokeOperator(calculator); calculator.Result = rightValue; calculator.Evaluate(); result = int.Parse(calculator.Result.ToString()); break; case EvaluateOption.ActualEvaluate: result = Evaluate(Left.Evaluate(option, calculator), Right.Evaluate(option, calculator)); break; } return(result); }
public override int Evaluate(EvaluateOption option, Calculator calculator) { if (Operand == null) { throw new InvalidOperationException(); } int result = 0; switch (option) { case EvaluateOption.UIEvaluate: calculator.Clear(); int operandEval = Operand.Evaluate(option, calculator); calculator.Clear(); calculator.Result = operandEval; InvokeOperator(calculator); calculator.Evaluate(); result = int.Parse(calculator.Result.ToString()); break; case EvaluateOption.ActualEvaluate: result = Evaluate(Operand.Evaluate(option, calculator)); break; } return(result); }
public abstract int Evaluate(EvaluateOption option, Calculator calculator);
public override int Evaluate(EvaluateOption option, Calculator calculator) { return(_number); }