Closed FZarsaz closed 2 years ago
public class Board { private char[][] arr;
public Board()
{
this.arr = new char[][]
{
new char[]{ '1', '2', '3' },
new char[]{ '4', '5', '6' },
new char[]{ '7', '8', '9' }
};
}
public int getRow(int index)
{
return ((index - 1) / 3);
}
public int getCol(int index)
{
return ((index - 1) % 3);
}
public boolean isEmpty(int index)
{
if (index < 1 || index > 9) return false;
int row = getRow(index);
int col = getCol(index);
if (this.arr[row][col] == 'o'|| this.arr[row][col] == 'x' )
return false;
return true;
}
public class Board { private char[][] arr;