Beispiel #1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                double firstNumber = Convert.ToDouble(textBox1.Text);

                IOoneCalculator calculator  = OneArgumentFactory.CreateCalculator(((Button)sender).Name);
                double          answerDigit = calculator.Calculate(firstNumber);

                textBox3.Text = answerDigit.ToString();
            }
            catch (Exception exc)
            {
                textBox3.Text = exc.Message;
            }
        }
Beispiel #2
0
        private void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                double operand = Convert.ToDouble(textBox1.Text);

                IOneArgumentCalculator calculator = OneArgumentFactory.CreateCalculator(((Button)sender).Name);

                var result = calculator.Calculate(operand);
                label1.Text = result.ToString();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Ошибка", MessageBoxButtons.OK);
            }
        }