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

            label1.Text = result.ToString();
        }
コード例 #2
0
 /// <summary>
 /// the function take one argument for calculate
 /// this need for sqrt/pow/etc
 /// a argument will be taken from the first input
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonClickForOneArgumentFunctions(object sender, EventArgs e)
 {
     try
     {
         double numberValueOne            = Convert.ToDouble(Value1.Text);
         IOneArgumentCalculate calculator = OneArgumentFactory.CreateFac(((Button)sender).Name);
         double result = calculator.OneArgCalculate(numberValueOne);
         this.textBox2.Text = result.ToString();
     }
     catch
     {
         MessageBox.Show("Ошибка");
     }
 }