I am working on a TicTacToe game and have to create several methods to handle various parts of the game. One of the methods is to clear the board for a new game. This is what I have for the method:
void resetBoard()
{
button_square_one = " ";
button_square_two = " ";
button_square_three = " ";
button_square_four = " ";
button_square_five = " ";
button_square_six = " ";
button_square_seven = " ";
button_square_eight = " ";
button_square_nine = " ";
}
In the onCreate() method:
// Assign button objects to ids
Button button_square_one = (Button)findViewById(R.id.r1c1_button);
Button button_square_two = (Button)findViewById(R.id.r1c2_button);
Button button_square_three = (Button)findViewById(R.id.r1c3_button);
Button button_square_four = (Button)findViewById(R.id.r2c1_button);
Button button_square_five = (Button)findViewById(R.id.r2c2_button);
Button button_square_six = (Button)findViewById(R.id.r2c3_button);
Button button_square_seven = (Button)findViewById(R.id.r3c1_button);
Button button_square_eight = (Button)findViewById(R.id.r3c2_button);
Button button_square_nine = (Button)findViewById(R.id.r3c3_button);
I have created the button objects in the xml file. I was going to create the methods with a return type of void instead of public void.