The following class, named SquareBoard.java, creates and prints out a game board for games such as Checkers, Chess, or TicTacToe. This means it can create an 8x8 board, a 3x3 board, or a board of any equal (square) dimensions.

The constructor method, a method to print out the board, and the main method are already provided. Your task is to complete a method named fillDiagonals that fills the two diagonals of the board with asterisks.

Notice that this class contains two instance variables: board, the String array containing the elements of the game board and length, the number of squares on each side of the board. Your method needs to use both of these variables.

Complete the following file:

SquareBoard.java

import java.util.Scanner; public class SquareBoard { /** Constructs an empty square game board. @param sideLength the length of each side */ public SquareBoard(int sideLength) { length = sideLength; board = new String[length][length]; // Fill with spaces for (int i = 0; i < length; i++) for (int j = 0; j < length; j++) board[i][j] = " "; } /** Creates a string representation of the board, such as |x o| | x | | o |. @return the string representation */ public String toString() { String r = ""; for (int i = 0; i < length; i++) { r = r + "|"; for (int j = 0; j < length; j++) r = r + board[i][j]; r = r + "|\n"; } return r; } /** Fills the diagonals of this square board with "*" strings. */ public void fillDiagonals() { // your work here } private String[][] board; private int length; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); SquareBoard chessBoard = new SquareBoard(n); chessBoard.fillDiagonals(); System.out.println(chessBoard.toString()); } }