Beispiel #1
0
        private void EqButton_Click(object sender, RoutedEventArgs e)
        {
            if (double.TryParse(resultLabel.Content.ToString(), out double newNumber))
            {
                switch (SelectedFunction)
                {
                case SelectedFunction.Addition:
                    result = SimpleMath.Add(lastNumber, newNumber);
                    break;

                case SelectedFunction.Subtraction:
                    result = SimpleMath.Subtract(lastNumber, newNumber);
                    break;

                case SelectedFunction.Multiplication:
                    result = SimpleMath.Mult(lastNumber, newNumber);
                    break;

                case SelectedFunction.Division:
                    result = SimpleMath.Div(lastNumber, newNumber);
                    break;
                }

                resultLabel.Content = result.ToString();
            }
        }
Beispiel #2
0
        private void equalButton_Click(object sender, RoutedEventArgs e)
        {
            double newNumber;

            if (double.TryParse(resultLabel.Content.ToString(), out newNumber))
            {
                switch (selectedOperator)
                {
                case SelectedOperator.Addition:
                    result = SimpleMath.Add(lastNumber, newNumber);
                    break;

                case SelectedOperator.Substraction:
                    result = SimpleMath.Subs(lastNumber, newNumber);
                    break;

                case SelectedOperator.Multiplication:
                    result = SimpleMath.Mult(lastNumber, newNumber);
                    break;

                case SelectedOperator.Division:
                    result = SimpleMath.Div(lastNumber, newNumber);
                    break;
                }
                //assign result
                resultLabel.Content = result.ToString();
            }
        }