Example #1
0
 /// <summary>
 ///  processing a click on "equal" button where is the main choice of further operations and functions
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void equally_Click(object sender, EventArgs e)
 {
     if (result1.Text.Length > 0) // textBox is not empty
     {
         secondNumber    = Convert.ToDouble(result1.Text);
         twonumber3.Text = result1.Text;
         СalculatorTwoVariables2 calculator = FactoryTwoArguments.CreateCalculator(Nametion);
         result = calculator.Calculate(firstNumber, secondNumber);
         def1();
     }
     result1.Focus();
 }
Example #2
0
 /// <summary>
 /// Эта часть кода отвечает за функции, с двумя операндами.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void rnd_Click2(object sender, EventArgs e)
 {
     try
     {
         ITwoArgument cal2 = FactoryTwoArguments.CreateCalculator(((Button)sender).Name);
         double       currnum1 = Convert.ToDouble(textBox1.Text), currnum2 = Convert.ToDouble(textBox2.Text);
         double       endres = cal2.Calculate(currnum1, currnum2);
         label1.Text = Convert.ToString(endres);
     }
     catch (Exception exc)
     {
         label1.Text = exc.Message;
     }
 }
Example #3
0
        public void CalculateTest(string name, Type type)
        {
            var calculator = FactoryTwoArguments.CreateCalculator(name);

            Assert.IsInstanceOf(type, calculator);
        }