October 2017
Beginner
318 pages
7h 26m
English
Let's begin by simply declaring and initializing the array we're going to be using. We'll use an array of characters for this task, giving the white squares the character value of W and the black squares the character value of B. Since a chessboard is an eight by eight grid, we're going to want to declare a two-dimensional array of eight arrays, each of which should contain eight characters:
char[][] board = new char[8][8];
Let's make things even more difficult for someone to inadvertently break in by storing the dimensions of our board in a separate location. To do this, simply create a variable called boardDim, for board dimensions, assign it the value 8, and then reference it when we create our arrays. ...
Read now
Unlock full access