//Stores the grid of what coin is in each cell public class draughtsMatrix { protected int[][] cellMatrix = new int[8][8]; public void draughtsMatrix () { } public void resetCellMatrix () { boolean firstRowTileHasCoin = false; int currentPlayerCoin = 0, currentCell = 0; for (int row = 1; row <= 8; row++) { if (row % 2 == 0) //If current row number is even (dividing by 2 does not give a remainder) { firstRowTileHasCoin = true; } else //Odd row number { firstRowTileHasCoin = false; } if (row <= 3) //Row 1,2,3 { currentPlayerCoin = 2; } else if (row > 3 && row < 6) //Row 4,5 { currentPlayerCoin = 0; } else //Row 6,7,8 { currentPlayerCoin = 1; } for (int column = 1; column <= 8; column++) { if (firstRowTileHasCoin) //Row 2,4,6,8 { if (column % 2 != 0) //If not an even number column { currentCell = currentPlayerCoin; //Column 1,3,5,7 } else { currentCell = 5; //Column 2,4,6,8 } } else //Row 1,3,5,7 { if (column % 2 != 0) //If not an even number column { currentCell = 5; //Column 1,3,5,7 } else { currentCell = currentPlayerCoin; //Column 2,4,6,8 } } cellMatrix[row - 1][column - 1] = currentCell; } } } public int getCell (int row, int column) { return cellMatrix[row][column]; } }