/** * Function name: checkLeft * @param board * @return count (int) * Inside the function * 1. using single loop to check the left diagnol to check same X/O * */ public static int checkLeft(char[][] board){ int count =0; for(int i=0; i<board.length;i++){ if(board[i][i]=='X'){ count++; } else if(board[i][i]=='O'){ count--; } } if(count==3|| count==-3){ return count; } else { count =0; } return count; }
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