October 2017
Beginner
318 pages
7h 26m
English
The thing is, each time this inner loop executes, we're going to want a different value for the nodes so that we get a chessboard that is alternating white and black squares. To help us do this, let's add another variable to our program. It'll be a Boolean variable, and we'll just call it isWhite. If isWhite is true, then the next square we add will be white; if isWhite is false, the square will be black.
To code this out, let's use some if statements. Firstly, the if(isWhite) code term checks whether isWhite is true. If it is, then we put a W in our square. If isWhite is false, we put a B in the square for black. To check whether something is not true, we can invert any Boolean value with an exclamation ...
Read now
Unlock full access