1 | On a checkerboard, every other square is filled |
2 | To accomplish this, we use the modulus operator (%) on the sum of the loop variables: if ( ( i + j ) % 2 == 0 ) { square.draw( g ); } else { square.fill( g ); } |
3 | Basically, "x % 2 == 0" checks if x is even |