ask user
Sat May 20 2023 13:21:25 GMT+0000 (Coordinated Universal Time)
Saved by
@gokulz
/**
* 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};
}
content_copyCOPY
Comments