예제 #1
0
        public void CalculateDivisionTestStrong(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("div");
            double result = calculator.Calculate(26, 13);

            Assert.AreEqual(2, result);
        }
예제 #2
0
        public void MinCalculatorTest()
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("Minimum");
            double result = calculator.Calculate(4, 2);

            Assert.AreEqual(2, result);
        }
        public void TestCalculate(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("addition_of_two_numbers");
            double result = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, result);
        }
예제 #4
0
        public void FirstTest(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("Max");
            double result = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, result, 0.01);
        }
예제 #5
0
        public void CalculateDegreeRootTestStrong(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("degreeroot");
            double result = calculator.Calculate(25, 2);

            Assert.AreEqual(5, result);
        }
예제 #6
0
        public ActionResult Calculate(double first, double second, string operation)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(operation);
            double result = calculator.Calculate(first, second);

            return(View(result));
        }
예제 #7
0
        public void CalculateLogXYTest(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("logxy");
            double result = calculator.Calculate(8, 2);

            Assert.AreEqual(3, result);
        }
예제 #8
0
        public void CalculateTest(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("Multiply");
            var actualResult = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, actualResult);
        }
예제 #9
0
        public ActionResult Index(double firstNumber, double secondNumber, string operation)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(operation);
            double result = calculator.Calculate(firstNumber, secondNumber);

            ViewBag.Result    = result;
            ViewBag.Operation = new SelectListItem[]
            {
                new SelectListItem()
                {
                    Value = "Multiplication", Text = "Multiplication"
                },
                new SelectListItem()
                {
                    Value = "Plus", Text = "Plus"
                },
                new SelectListItem()
                {
                    Value = "Minus", Text = "Minus"
                },
                new SelectListItem()
                {
                    Value = "Division", Text = "Division"
                }
            };
            return(View());
        }
예제 #10
0
        public ActionResult Index(double firstArgument, double secondArgument, string operation)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(operation);
            double result = calculator.Calculate(firstArgument, secondArgument);

            ViewBag.Result    = result;
            ViewBag.Operation = new SelectListItem[]
            {
                new SelectListItem()
                {
                    Value = "SolutionMulti", Text = "Multi"
                },
                new SelectListItem()
                {
                    Value = "SolutionPlus", Text = "Plus"
                },
                new SelectListItem()
                {
                    Value = "SolutionMinus", Text = "Minus"
                },
                new SelectListItem()
                {
                    Value = "SolutionDiv", Text = "Div"
                }
            };
            return(View());
        }
예제 #11
0
        public void CalculateXDivYTestStrong(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("xdivy");
            double result = calculator.Calculate(5, 2);

            Assert.AreEqual(2, result);
        }
예제 #12
0
        /// <summary>
        /// Handler for operations with two arguments
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void CalculateTwoArguments(object sender, EventArgs e)
        {
            try
            {
                string InputOne = ValueOneInput.Text;
                string InputTwo = ValueTwoInput.Text;

                if (InputOne.Length == 0 || InputTwo.Length == 0)
                {
                    throw new Exception("Argument missing");
                }

                string senderName    = ((Button)sender).Name;
                string operationName = senderName.Replace("Button", "");

                double firstValue  = MyValidator.ValidateAndConvertToDouble(ValueOneInput.Text);
                double secondValue = MyValidator.ValidateAndConvertToDouble(ValueTwoInput.Text);

                ITwoArgumentsCalculator Calculator = TwoArgumentsFactory.CreateCalculator(operationName);
                var calculateResult = Calculator.Calculate(firstValue, secondValue);

                OutputField.Text = calculateResult.ToString();
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error");
            }
        }
예제 #13
0
        public void TestCalculate(double firstValue, double secondValue, double expected)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("DegreeRoot");
            double result = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, result);
        }
예제 #14
0
        public void FirstTest()
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator("Multiply");
            double result = calculator.Calculate(5, 5);

            Assert.AreEqual(25, result);
        }
예제 #15
0
        public ActionResult Index(double firstNumber, double secondNumber, string operation)
        {
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(operation);

            ViewBag.result     = calculator.Calculate(firstNumber, secondNumber);
            ViewBag.operations = operations;
            return(View());
        }
예제 #16
0
        private void ClickTwo(object sender, EventArgs e)
        {
            double first                       = Convert.ToDouble(textBox1.Text);
            double second                      = Convert.ToDouble(textBox2.Text);
            string calculationName             = ((Button)sender).Name;
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(calculationName);
            double result                      = calculator.Calculate(first, second);

            label1.Text = Convert.ToString(result);
        }
예제 #17
0
파일: Form1.cs 프로젝트: Rama322/calculator
        private void Calculate_click(object sender, EventArgs e)
        {
            double firstArgument  = Convert.ToDouble(textBox1.Text);
            double secondArgument = Convert.ToDouble(textBox2.Text);
            double result;

            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);

            result        = calculator.Calculate(firstArgument, secondArgument);
            textBox3.Text = result.ToString();
        }
예제 #18
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);
        }
예제 #19
0
        private void button_Click(object sender, EventArgs e)
        {
            string firstValueText              = textBox5.Text;
            double firstValue                  = Convert.ToDouble(firstValueText);
            string secondValueText             = textBox6.Text;
            double secondValue                 = Convert.ToDouble(secondValueText);
            string calculatorName              = ((Button)sender).Name;
            ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(calculatorName);
            double result = calculator.Calculate(firstValue, secondValue);

            label2.Text = Convert.ToString(result);
        }
예제 #20
0
        private void Click(object sender, EventArgs e)
        {
            string Transmission    = ((Button)sender).Name;
            string firstValueText  = textBox3.Text;
            double firstValue      = Convert.ToDouble(firstValueText);
            string secondValueText = textBox4.Text;
            double secondValue     = Convert.ToDouble(secondValueText);

            ITwoArgumentsCalculator calculator = TwoArgumentFactory.createCalculate(Transmission);
            double result = calculator.Calculate(firstValue, secondValue);

            textBox5.Text = result.ToString();
        }
예제 #21
0
 private void button_Click(object sender, EventArgs e)
 {
     try
     {
         double firstNumber  = Convert.ToDouble(textNumber1.Text);
         double secondNumber = Convert.ToDouble(textNumber2.Text);
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(firstNumber, secondNumber);
         textResult.Text = result.ToString();
     }
     catch (Exception ex)
     {
         textResult.Text = "mistake: " + ex.Message;
     }
 }
예제 #22
0
파일: Form1.cs 프로젝트: Qweur/-Calculator
 private void Calculate(object sender, EventArgs e)
 {
     try
     {
         double firstOperand  = Convert.ToDouble(Input1.Text);
         double secondOperand = Convert.ToDouble(Input2.Text);
         ITwoArgumentsCalculator calculator = TwoArgumentCalculatorsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(firstOperand, secondOperand);
         Result.Text = result.ToString(CultureInfo.InvariantCulture);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
예제 #23
0
 private void act_Click(object sender, EventArgs e)
 {
     try
     {
         double firstArgument  = Convert.ToDouble(textBox1.Text);
         double secondArgument = Convert.ToDouble(textBox2.Text);
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(firstArgument, secondArgument);
         label1.Text = Convert.ToString(result);
     }
     catch (Exception exc)
     {
         MessageBox.Show("ошибка: " + exc.Message);
     }
 }
예제 #24
0
 private void TwoArgumentFunction(object sender, EventArgs e)
 {
     try
     {
         double firstArgument  = Convert.ToDouble(argument_1.Text);
         double secondArgument = Convert.ToDouble(argument_2.Text);
         ITwoArgumentsCalculator calculator = TwoArgumentFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(firstArgument, secondArgument);
         TotalResult.Text = result.ToString();
     }
     catch (Exception exc)
     {
         TotalResult.Text = exc.Message;
     }
 }
예제 #25
0
 private void ClickTwo(object sender, EventArgs e)
 {
     try
     {
         double firstArgument  = Convert.ToDouble(textBox1.Text);
         double secondArgument = Convert.ToDouble(textBox2.Text);
         ITwoArgumentsCalculator calculator = Factory.CreateCalculator((((Button)sender).Name));
         double result = calculator.Calculate(firstArgument, secondArgument);
         textBox3.Text = result.ToString();
     }
     catch (Exception two)
     {
         textBox3.Text = two.Message;
     }
 }
예제 #26
0
 private void TwoArgumentButtonClick(object sender, EventArgs e)
 {
     try
     {
         double first  = Convert.ToDouble(Input1.Text);
         double second = Convert.ToDouble(Input2.Text);
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(first, second);
         Result.Text = Convert.ToString(result);
     }
     catch (Exception exc)
     {
         MessageBox.Show("Возникла ошибка:" + exc.Message);
     }
 }
예제 #27
0
 private void CalculateTest(object sender, EventArgs e)
 {
     try
     {
         double first  = Convert.ToDouble(textBox1.Text);
         double second = Convert.ToDouble(textBox2.Text);
         ITwoArgumentsCalculator Calculator = FactoryTwoArguments.CreateCalculate(((Button)sender).Name);
         double result = Calculator.Calculate(first, second);
         textBox3.Text = result.ToString();
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
예제 #28
0
 private void btn_Click(object sender, EventArgs e)
 {
     try
     {
         double firstArgument  = Convert.ToDouble(textBox1.Text);
         double secondArgument = Convert.ToDouble(textBox2.Text);
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
         double result = calculator.Calculate(firstArgument, secondArgument);
         textBox3.Text = result.ToString(CultureInfo.InvariantCulture);
     }
     catch (Exception exception)
     {
         textBox3.Text = exception.Message;
     }
 }
예제 #29
0
        private void Calculate(object sender, EventArgs e)
        {
            try
            {
                double firstArgument  = Convert.ToDouble(textBox1.Text);
                double secondArgument = Convert.ToDouble(textBox2.Text);

                ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
                var result = calculator.Calculate(firstArgument, secondArgument);
                textBox3.Text = result.ToString();
            }
            catch (Exception exc)
            {
                textBox3.Text = "Error:" + exc.Message;
            }
        }
예제 #30
0
 private void Calculate(object sender, EventArgs e)
 {
     try
     {
         double firstNumber  = Convert.ToDouble(this.textBox1.Text);
         double secondNumber = Convert.ToDouble(this.textBox2.Text);
         double result;
         ITwoArgumentsCalculator calculator = TwoArgumentsFactory.CreateCalculator(((Button)sender).Name);
         result        = calculator.calculate(firstNumber, secondNumber);
         textBox3.Text = result.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }