1 import java.util.Scanner;
2
3 /**
4 This program runs a TicTacToe game. It prompts the
5 user to set positions on the board and prints out the
6 result.
7 */
8 public class TicTacToeRunner
9 {
10 public static void main(String[] args)
11 {
12 Scanner in = new Scanner(System.in);
13 String player = "x";
14 TicTacToe game = new TicTacToe();
15 boolean done = false;
16 while (!done)
17 {
18 System.out.print(game.toString());
19 System.out.print(
20 "Row for " + player + " (-1 to exit): ");
21 int row = in.nextInt();
22 if (row < 0) done = true;
23 else
24 {
25 System.out.print("Column for " + player + ": ");
26 int column = in.nextInt();
27 game.set(row, column, player);
28 if (player.equals("x"))
29 player = "o";
30 else
31 player = "x";
32 }
33 }
34 }
35 }