Skip to content

Commit 9acc7c9

Browse files
committed
added TicTacToe\src\com\game\tictactoe\Player.java
1 parent dcf49d8 commit 9acc7c9

File tree

1 file changed

+39
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)