void ApplyToCurrentValue(string s) { if (currentValue == null) { currentValue = new Value(); valueStack.Push(currentValue); } currentValue.apply(s); }
void PopOperatorAndCalculate() { if (operatorStack.Count > 0 && valueStack.Count > 1) { var op = operatorStack.Pop(); var right = valueStack.Pop(); var left = valueStack.Pop(); var result = op.Operate(left, right); var value = new Value(); value.apply(result.ToString()); valueStack.Push(value); } }
public void Input(string expression) { if (expression.Equals("C")) { currentValue = null; } else { if (currentValue == null) { currentValue = new Value(); } currentValue.apply(expression); } }