コード例 #1
0
ファイル: Form1.cs プロジェクト: KamilaMuborakova/Kamila
        private void ButtonClick(object sender, EventArgs e)
        {
            string firstValueText             = TextBox1.Text;
            double firstValue                 = Convert.ToDouble(firstValueText);
            string secondValueText            = textBox2.Text;
            double secondValue                = Convert.ToDouble(secondValueText);
            string operation                  = ((Button)sender).Name;
            ITwoArgumentsCalculate calculator = TwoArgumentFactory.CreateCalculator(operation);
            double result = calculator.Calculate(firstValue, secondValue);

            label1.Text = result.ToString();
        }
コード例 #2
0
 /// <summary>
 /// the function output on display result (take two arguments for input)
 /// and the function for create calculate for needed a button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonClickForTwoArgumentsFunctions(object sender, EventArgs e)
 {
     try
     {
         double numberValueOne             = Convert.ToDouble(Value1.Text);
         double numberValueTwo             = Convert.ToDouble(Value2.Text);
         ITwoArgumentsCalculate calculator = TwoArgumentsFactory.CreateCalc(((Button)sender).Name);
         double result = calculator.TwoArgCalculate(numberValueOne, numberValueTwo);
         this.textBox2.Text = result.ToString();
     }
     catch
     {
         MessageBox.Show("Ошибка");
     }
 }
コード例 #3
0
        public void CalculateDivide2()
        {
            ITwoArgumentsCalculate calculator = TwoArgumentFactory.CreateCalculator("Divide");

            Assert.Throws <Exception>(() => calculator.Calculate(7, 0));
        }