-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameBoard.java
More file actions
35 lines (27 loc) · 798 Bytes
/
GameBoard.java
File metadata and controls
35 lines (27 loc) · 798 Bytes
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
public class GameBoard {
private GameToken [][] board;
private GameToken player, blank;
public GameBoard(int rows, int cols) {
player= new GameToken(true, false, true);
blank= new GameToken(false, false, false);
board = new GameToken[rows][cols];
for(int i = 0; i < rows; i++){
for(int j = 0; j < cols;j++){
board[i][j] = blank;
}
}
board[0][0] = player;
board[0][1] = player;
}
public int countCharacters() {
int x = 0;
for(int i = 0; i < board.length; i++){
for(int j = 0; j < board[0].length; j++){
if(board[i][j] != blank) {
x++;
}
}
}
return x;
}
}