Esempio n. 1
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.Sustraction:
                    result = SimpleMath.Substract(lastNumber, newNumber);
                    break;

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

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

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

            if (double.TryParse(lblResult.Content.ToString().Replace(",", "."), out currentNumber))
            {
                switch (SelOper)
                {
                case SelectedOperator.Addition:
                    result = SimpleMath.Add(lastNumber, currentNumber);
                    break;

                case SelectedOperator.Substraction:
                    result = SimpleMath.Substract(lastNumber, currentNumber);
                    break;

                case SelectedOperator.Multiplication:
                    result = SimpleMath.Multiply(lastNumber, currentNumber);
                    break;

                case SelectedOperator.Divition:
                    result = SimpleMath.Divide(lastNumber, currentNumber);
                    break;

                case SelectedOperator.None:
                    result = 0;
                    break;

                default:
                    result = 0;
                    break;
                }
                lblResult.Content = result.ToString().Replace(",", ".");
            }
        }
Esempio n. 3
0
        private void EqualsBtn_Click(object sender, RoutedEventArgs e)
        {
            if (double.TryParse(resultLabel.Content.ToString(), out double newNumber))
            {
                switch (SelectedOperator)
                {
                case SelectedOperator.Sum:
                    result = SimpleMath.Sum(lastNumber, newNumber);
                    break;

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

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

                case SelectedOperator.Divide:
                    result = SimpleMath.Divide(lastNumber, newNumber);
                    break;
                }
                resultLabel.Content = result;
            }
        }
Esempio n. 4
0
        private void Equal_Click(object sender, RoutedEventArgs e)
        {
            if (double.TryParse(Result.Text.ToString(), out double newNumber)) // Declaração do número novo dentro do argumento
            {
                switch (_selectedOperator)
                {
                case SelectedOperator.Addition:
                    _result = SimpleMath.Add(_lastNumber, newNumber);
                    break;

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

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

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

            Result.Text = $"{_result}";
        }