Пример #1
0
        private void equlButton_Click(object sender, RoutedEventArgs e)
        {
            double newNumber;
            bool   divisionZero = false;

            newNumber = double.Parse(resultLabel.Content.ToString());

            switch (selectedOperator)
            {
            case SelectedOperator.Addition:
                result = SimpleMath.Add(lastNumber, newNumber);
                break;

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

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

            case SelectedOperator.Division:
                if (newNumber != 0)
                {
                    result = SimpleMath.Division(lastNumber, newNumber);
                }
                else
                {
                    divisionZero = true;
                    lastNumber   = 0;
                }
                break;
            }

            if (divisionZero)
            {
                resultLabel.FontSize = 30;
                resultLabel.Content  = "0 으로 나눌 수 없습니다.";
            }
            else
            {
                resultLabel.Content = result.ToString();
            }
        }