Beispiel #1
0
 /// <summary>
 /// Acceptance of value and output of the result
 /// </summary>
 /// <param name="sender">Sending the name of the pressed button</param>
 /// <param name="e">Provides value for events that do not contain data</param>
 private void Sincos(object sender, EventArgs e)
 {
     try
     {
         double firstValue = Convert.ToDouble(textBox1.Text);
         IOneArgumentCalculator calculator = OneArgumentCalculatorFactory.CreateCalculator(((Button)sender).Name);
         var result = calculator.Calculate(firstValue);
         textBox3.Text = result.ToString();
     }
     catch (Exception exp)
     {
         textBox3.Text = exp.Message;
     }
 }
Beispiel #2
0
 /// <summary>
 /// method for processing button clicks for one argument operations
 /// </summary>
 private void OpertionForOneArgument(object sender, EventArgs e)
 {
     try
     {
         double argument      = Convert.ToDouble(firstArgument.Text);
         string operationName = ((Button)sender).Name;
         IOneArgumentCalculator calculator = OneArgumentCalculatorFactory.CreateCalculator(operationName);
         double resultValue = calculator.Calculate(argument);
         result.Text = Convert.ToString(resultValue);
     }
     catch (FormatException exc)
     {
         result.Text = "Введите число";
     }
     catch (Exception exc)
     {
         result.Text = exc.Message;
     }
 }
Beispiel #3
0
        public void CalculateTest(string name, Type type)
        {
            var calculator = OneArgumentCalculatorFactory.CreateCalculator(name);

            Assert.IsInstanceOf(type, calculator);
        }