示例#1
0
        private void EqualtoButton_Click(object sender, RoutedEventArgs e)
        {
            double newNumber;

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

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

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

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

                resultLabel.Content = result.ToString();
            }
        }
        private void BtnResult_Click(object sender, RoutedEventArgs e)
        {
            double newNumber;

            if (double.TryParse(LblResult.Content.ToString(), out newNumber))
            {
                switch (selectedOperator)
                {
                case SelectedOperator.Addition:
                    _result = SimpleMath.Addition(_lastNumber, newNumber);
                    break;

                case SelectedOperator.Subtraction:
                    _result = SimpleMath.Subtraction(_lastNumber, newNumber);
                    break;

                case SelectedOperator.Multiplication:
                    _result = SimpleMath.Multiplication(_lastNumber, newNumber);
                    break;

                case SelectedOperator.Division:
                    _result = SimpleMath.Division(_lastNumber, newNumber);
                    break;
                }

                LblResult.Content = _result.ToString();
            }
        }
示例#3
0
        private void EqualsButton_Click(object sender, RoutedEventArgs e)
        {
            // throw new NotImplementedException();
            double newNumber;

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

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

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

                case SelectedOperator.Subtraction:
                    result = SimpleMath.Subtraction(lastNumber, newNumber);
                    break;
                }
            }

            resultLabel.Content = result.ToString();
        }