I have made a simple tic tac toe game app using java.it is working as required, but after wining form one side it is keep taking the value. How to stop the execution after certain condition meet.
If this is one of the condition of declaring the winner
else if (b1.equals(b4) && b4.equals(b7) && !b4.equals("")) {
Toast.makeText(this, "Winner is " + b1, Toast.LENGTH_LONG).show();
then what should do to stop taking the input from all the button until restart?
3
Answers
i am not sure if i get your question but you can do it in while loop such as
and you can just update the value of condition after it finished.
You can always disable the buttons after that condition is met:
Since you’re saying you don’t want the user to continue the game after it ended, you can also create an alert dialog, telling the game has ended, and when the user clicks "Ok" it restarts the game:
You can set button.setEnabled(false) after your condition is satisfied.