-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.java
39 lines (27 loc) · 868 Bytes
/
Player.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.game.tictactoe;
import java.util.Scanner;
public class Player {
public static char[][] TABLE = new char[3][3];
public static String[] ARGS = new String[2]; // array to store the position
// in the 2 dimensional
public static void main(String[] args) { // array
String CHOICE = "";
System.out.println("Enter coordinates: ");
Scanner sc = new Scanner(System.in);
String coords = sc.nextLine();
ARGS = coords.split(" ");
int C = Integer.parseInt(ARGS[0]) - 1;
int R = Integer.parseInt(ARGS[1]) - 1;
TABLE[R][C] = CHOICE.charAt(0);
createTable(TABLE);
sc.close();
}
public static void createTable(char[][] TABLE) {
for (int j = 0; j < TABLE.length; j++) {
for (int k = 0; k < TABLE[0].length; k++) {
System.out.print("[" + TABLE[j][k] + "]");
}
System.out.println();
}
}
}