/**
* Funtion Name: askUser
* @param board
* @return int[] row col
*
* Inside the Function
* --> Pick a Row and column
* --> Loop to check if the spot is already taken
* --> if spot is already taken again pick a row and column
*/
public static int[] askUser(char[][] board){
System.out.print("Pick a Row and Column: ");
int row = sc.nextInt();
int col = sc.nextInt();
while(board[row][col]=='X' || board[row][col]=='O'){
System.out.print("The Spot already taken: ");
row = sc.nextInt();
col = sc.nextInt();
}
return new int[] {row, col};
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter