import java.util.Scanner; public class TicTacToe{ static Scanner sc = new Scanner(System.in); // the scanner class can access by all the methods public static void main(String[] args) { // create a 2d character array full of dashes char[][] board = {{'-','-','-'}, {'-','-','-'}, {'-','-','-'} }; for(int i=0; i<9; i++){ if(i%2==0){ System.out.println("Turn: X"); int[] spot = askUser(board); board[spot[0]][spot[1]] = 'X'; printBoard(board); } else{ System.out.println("Turn: O"); int[] spot = askUser(board); board[spot[0]][spot[1]] = 'O'; printBoard(board); }
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