예제 #1
0
 void ApplyToCurrentValue(string s)
 {
     if (currentValue == null)
     {
         currentValue = new Value();
         valueStack.Push(currentValue);
     }
     currentValue.apply(s);
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
 public void Input(string expression)
 {
     if (expression.Equals("C"))
     {
         currentValue = null;
     }
     else
     {
         if (currentValue == null)
         {
             currentValue = new Value();
         }
         currentValue.apply(expression);
     }
 }