I dont know how to test my calc in C# program because my methods are working exactly with (object sender, EventArgs e) parameters and with global variables. How could test to this method look like?
This is only one part of the code
private void buttonEq_Click(object sender, EventArgs e)
{
number2 = int.Parse(textBox1.Text);
if (operation == "plus")
{
finRes = number1 + number2;
}
else if (operation == "minus")
{
finRes = number1 - number2;
}
else if (operation == "multiple")
{
finRes = number1 * number2;
}
else if (operation == "divide")
{
finRes = number1 / number2;
}
else if (operation == "exp")
{
finRes = Math.Pow(number1, number2);
}
else if (operation == "fac")
{
int result = number1;
for (int i = (number1)-1; i > 0 ; i--)
{
result = result * i;
finRes = result;
}
}
else if (operation == "sqrt")
{
finRes = Math.Sqrt(number1);
}
textBox2.Text = finRes.ToString();
operation = "";
}
Aucun commentaire:
Enregistrer un commentaire