Пример #1
0
 private void CheckButton_Click(object sender, EventArgs e)
 {
     try
     {
         double firstNumber  = Convert.ToDouble(FirstField.Text);
         double secondNumber = Convert.ToDouble(SecondField.Text);
         ITwoArgumentCalculators calculator = TwoArgumentCalculatorsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(firstNumber, secondNumber);
         Result.Text = result.ToString();
     }
     catch (Exception ty)
     {
         MessageBox.Show("Ошибка: " + ty.Message);
     }
 }
Пример #2
0
 private void Calculate(object sender, EventArgs e)
 {
     try
     {
         double firstOperand  = Convert.ToDouble(Input1.Text);
         double secondOperand = Convert.ToDouble(Input2.Text);
         ITwoArgumentsCalculator calculator = TwoArgumentCalculatorsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(firstOperand, secondOperand);
         Result.Text = result.ToString(CultureInfo.InvariantCulture);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
        public void CreateCalculateTest(string name, Type type)
        {
            var calculator = TwoArgumentCalculatorsFactory.CreateCalculator(name);

            Assert.IsInstanceOf(type, calculator);
        }