Created
September 13, 2020 22:05
-
-
Save gonaumov/e577f5db4402741eb2eeacea44684b21 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tictactoe; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in).useDelimiter(""); | |
char[][] state = new char[3][3]; | |
int i = 0; | |
int j = 0; | |
int size = state.length - 1; | |
System.out.print(Messages.ASK.message); | |
while (true) { | |
state[i][j] = scanner.next().charAt(0); | |
if (j < size) { | |
j++; | |
} else if ( i < size) { | |
j = 0; | |
i++; | |
} else { | |
break; | |
} | |
} | |
scanner.reset(); | |
scanner.nextLine(); | |
TikTakToeGame game = new TikTakToeGame(state); | |
System.out.println(game.getState()); | |
boolean result; | |
System.out.print(Messages.ASK_COORDINATES.message); | |
do { | |
String input = scanner.nextLine(); | |
result = game.validateUserInput(input); | |
} while (!result); | |
game.updateCoordinates('X'); | |
System.out.println(game.getState()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment