1
import java.util.Scanner;
5
Scanner scanner = new Scanner(System.in);
6
char whoMakeNextTurn; boolean gameOver = false;
9
System.out.println("Will play new X0 game");
10
this.gameField = new FieldX0(); this.gameField.initField();
14
System.out.println("Who will make first turn: ");
15
char first = this.scanner.next().charAt(0);
16
if (first == 'X' || first == '0') {
17
this.whoMakeNextTurn = first;
19
else { System.out.println("I recognizing only X and 0 (zero). So first will be X");
20
this.whoMakeNextTurn = 'X';
23
turn(); this.gameOver = this.gameField.isGameOver(this.whoMakeNextTurn);
25
System.out.println(this.whoMakeNextTurn + " win!");
27
if (this.whoMakeNextTurn == 'X') {
28
this.whoMakeNextTurn = '0';
31
this.whoMakeNextTurn = 'X';
33
} System.out.println("Game over.");
36
System.out.println(this.whoMakeNextTurn + ", your turn. ");
37
System.out.print("Chose row: "); int rowNumber = this.scanner.nextInt();
38
System.out.print("Chose column: "); int colNumber = this.scanner.nextInt(); int rowIndex = rowNumber - 1; int colIndex = colNumber - 1;
39
if (this.gameField.isPlaceFree(rowIndex, colIndex)) {
40
this.gameField.setValue(rowIndex, colIndex, whoMakeNextTurn);
41
this.gameField.printField(); }
43
System.out.println("Wrong number (maybe this place is not free?). Make turn again"); turn();