-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmat.java
53 lines (47 loc) · 1.33 KB
/
mat.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
public class mat {
char board[][] = new char[3][3];
boolean full = false;
int number = 0;
int tiles = 0;
char winner = '0';
public mat (){
// System.out.println("play piece");
board[0][0] = '1';
board[0][1] = '2';
board[0][2] = '3';
board[1][0] = '4';
board[1][1] = '5';
board[1][2] = '6';
board[2][0] = '7';
board[2][1] = '8';
board[2][2] = '9';
printBoard();
}
public void printBoard() {
System.out.println();
System.out.println("Board: "+number);
System.out.println("-------------");
for (int i = 0; i < 3; i++) {
System.out.print("| ");
for (int j = 0; j < 3; j++) {
System.out.print(board[i][j] + " | ");
}
System.out.println();
System.out.println("-------------");
}
}
public void playPiece(char location, player p) {//finds desired location and replaces array with player's piece.
//System.out.println("called");
//System.out.println(location);
//System.out.println(p.getPiece());
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if(location == board[i][j]) {
board[i][j] = p.getPiece();
tiles++;
}
}
}
printBoard();
}
}