コード例 #1
0
        public ActionResult Calculate(double firstValue, double lastValue, string operation)
        {
            var    calc        = TwoArgumentsFatory.CreateCalculator(operation);
            double resultValue = calc.Calculate(firstValue, lastValue);

            return(View(resultValue));
        }
コード例 #2
0
 private void Calculate_Click(object sender, EventArgs e)
 {
     try
     {
         double firstValue  = Convert.ToDouble(textBox1.Text);
         double lastValue   = Convert.ToDouble(textBox2.Text);
         var    calc        = TwoArgumentsFatory.CreateCalculator(((Button)sender).Name);
         double resultValue = calc.Calculate(firstValue, lastValue);
         textBox3.Text = resultValue.ToString();
     }
     catch (Exception exception)
     {
         MessageBox.Show("Возникла ошибка: " + exception.Message);
     }
 }
コード例 #3
0
        public void CalculateTest(string name, Type type)
        {
            var calculator = TwoArgumentsFatory.CreateCalculator(name);

            Assert.IsInstanceOf(type, calculator);
        }