Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

how do you start off a boolean?

+1 vote
asked Feb 13, 2015 in (Winter 14) by Rafael Rodriguez (100 points)
Your question should probably be clarified... exactly *what* are you trying to do with a boolean?  Use a boolean expression in a WHILE loop?  An IF statement?  Use a boolean variable to keep track of something?

1 Answer

+1 vote
Here is an example from my Tic Tac Toe project:

boolean done = false;
                while (!done) {
                    playTurn(panel, g, turn);
                }

Essentially, until done is declared true, the game will continue to play turns of Tic Tac Toe. Hope this helps!
answered Feb 13, 2015 by Greg Larson (100 points)
Note that Greg's simplified example is an INFINITE loop, since done is never assigned the value false.    You might want to include an additional IF statement inside the loop, like this:

if (xWon || yWon || numTurns == 9) {
   done = true;
}
...