public void TestCalculate(double firstValue, double expected) { IOneArgumentsCalculator calculator = OneArgumentsFactory.CreateCalculator("ten_in_th_degree"); double result = calculator.Calculate(firstValue); Assert.AreEqual(expected, result); }
public void TestCalculate(double firstValue, double expected) { IOneArgumentsCalculator calculator = OneArgumentsFactory.CreateCalculator("squareroot"); double result = calculator.Calculate(firstValue); Assert.AreEqual(expected, result); if (firstValue < 0) { throw new Exception("Не верный индетефикатор"); } }
private void button_Click(object sender, EventArgs e) { try { string firstArgument = textBox1.Text; string nameButton = ((Button)sender).Name; IOneArgumentsCalculator calculator = OneArgumentsFactory.CreateCalculator(nameButton); textBox1.Text = calculator.Calculate(firstArgument); } catch (Exception exception) { textBox1.Text = exception.Message; } }
private void btn_ClickOneArgument(object sender, EventArgs e) { try { double firstArgument = Convert.ToDouble(textBox1.Text); IOneArgumentsCalculator calculator = OneArgumentsFactory.CreateCalculator(((Button)sender).Name); double result = calculator.Calculate(firstArgument); textBox3.Text = result.ToString(CultureInfo.InvariantCulture); } catch (Exception exception) { textBox3.Text = exception.Message; } }
private void OneArgumentButtonClick(object sender, EventArgs e) { try { double first = Convert.ToDouble(Input1.Text); IOneArgumentsCalculator calculator = OneArgumentsFactory.CreateCalculator(((Button)sender).Name); double result = calculator.Calculate(first); Result.Text = Convert.ToString(result); } catch (Exception exc) { MessageBox.Show("Возникла ошибка:" + exc.Message); } }
private void OneArgument(object sender, EventArgs e) { try { double argument = Convert.ToDouble(textBox1.Text); double result = 0.0; IOneArgumentsCalculator calculator = FactoryOneArgument.CreateCalculate(((Button)sender).Name); result = calculator.Calculate(argument); textBox3.Text = result.ToString(); } catch (Exception exc) { MessageBox.Show(exc.Message); } }
private void OneArgumentOperation(object sender, EventArgs e) { try { String variable1 = textBox1.Text; double firstArgument = Convert.ToDouble(variable1); String variable2 = textBox2.Text; string operation = ((Button)sender).Name; IOneArgumentsCalculator calculator = OneArgumentsFactory.CreateCalculator(operation); double result = calculator.Calculate(firstArgument); textBox3.Text = Convert.ToString(result); } catch (Exception exc) { textBox3.Text = exc.Message; } }