예제 #1
0
        private void calcAndPushResult(string op = "")
        {
            // 1
            if (calcElement.number2 == null)
            {
                calcElement.number2 = createNumberFromDigits(inputNumbers);
                inputNumbers        = new List <int>();
            }

            calcElements.Add(calcElement);

            // calc
            int returVal = 0;

            foreach (CalcElement tmpCalcElement in calcElements)
            {
                returVal = tmpCalcElement.chooseCalcMethod();
            }

            calcElements = new List <CalcElement>();

            // 2
            calcElement         = new CalcElement();
            calcElement.number1 = returVal;
            if (!String.IsNullOrEmpty(op))
            {
                calcElement.op = op;
            }
        }
예제 #2
0
        private void ButtonPlus_Click(object sender, RoutedEventArgs e)
        {
            calcElement.op = "+";

            if (calcElement.number1 == null)
            {
                calcElement.number1 = createNumberFromDigits(inputNumbers);
                inputNumbers        = new List <int>();
            }
            else if (calcElement.number2 == null)
            {
                calcAndPushResult("+");
            }
            else
            {
                calcElements.Add(calcElement);
                calcElement = new CalcElement();
            }
        }