Exemple #1
0
        public ActionResult Index(double firstNumber, double secondNumber, string operation)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsCalculatorFactory.CreateCalculator(operation);

            ViewBag.result     = calculator.Calculate(firstNumber, secondNumber);
            ViewBag.operations = operations;
            return(View());
        }
 public void TwoArgumentsButtonClick(object sender, EventArgs e)
 {
     try
     {
         Button clickedButton = (Button)sender;
         double number1       = Convert.ToDouble(Number1Field.Text);
         double number2       = Convert.ToDouble(Number2Field.Text);
         ITwoArgumentsCalculator calculator = TwoArgumentsCalculatorFactory.CreateCalculator(clickedButton.Text);
         double result = calculator.Calculate(number1, number2);
         ResultField.Text = result.ToString();
     }
     catch (Exception exc)
     {
         ResultField.Text = exc.Message;
     }
 }
Exemple #3
0
        public void CalculateTest(string name, Type type)
        {
            var calculator = TwoArgumentsCalculatorFactory.CreateCalculator(name);

            Assert.IsInstanceOf(type, calculator);
        }