jeudi 26 mars 2015

c# If else if statement event triggers before else if does

so I have hidden buttons, that I only want to show when maxAttempts has been reached, with the code below, the buttons open after the first wrong attempt. Also while I'm at it, I want to disable a button and a textbox at game over, but when I write btncheckAnswer.disable and txtResult.disable I see exceptions.


Any suggestions?



private void btnCheckAnswer_Click(object sender, EventArgs e)
{

var userAnswer = double.Parse(txtResult.Text);
if (!puzzle.CheckTheAnswer(userAnswer))
{
MessageBox.Show("Wrong");
numAttempts++;
if (numAttempts < maxAttempts)
{ // UpdateImage();
NextQuestion();
}
else
if (numAttempts == maxAttempts)
{
MessageBox.Show("Game Over");
btnClose.Show();
btnNewGame.Show();
//btnCheckAnswer.disable();
//txtResult.disable;()
//Stop the game ();
//Block text box from receiving data

return;
}

}

else MessageBox.Show("Smarty Pants, You're Right!!");
{
NextQuestion();
}
return;

Aucun commentaire:

Enregistrer un commentaire