Esempio n. 1
0
        private void Additionoftwo(object sender, EventArgs e)
        {
            String variable1      = textBox1.Text;
            double firstArgument  = Convert.ToDouble(variable1);
            String variable2      = textBox2.Text;
            double secondArgument = Convert.ToDouble(variable2);
            string operation      = ((Button)sender).Name;
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(operation);
            double result = calculator.Calculate(firstArgument, secondArgument);

            textBox3.Text = Convert.ToString(result);
        }
Esempio n. 2
0
 private void TwoArgumentsOperation(object sender, EventArgs e)
 {
     try
     {
         String variable1      = textBox1.Text;
         double firstArgument  = Convert.ToDouble(variable1);
         String variable2      = textBox2.Text;
         double secondArgument = Convert.ToDouble(variable2);
         string operation      = ((Button)sender).Name;
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(operation);
         double result = calculator.Calculate(firstArgument, secondArgument);
         textBox3.Text = Convert.ToString(result);
     }
     catch (Exception exc)
     {
         textBox3.Text = exc.Message;
     }
 }