Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132930 views
License: OTHER
1
public class ConnectFourGame implements Cloneable {
2
private Color[][] board = new Color[7][6];
3
private Color lastMove;
4
private Color winner;
5
private boolean isFinished = false;
6
7
//[...]
8
9
public void printBoard() {
10
for (byte y = 5; y >= 0; y--) {
11
System.out.print(y + " ");
12
for (byte x = 0; x < 7; x++) {
13
if (board[x][y] == null) {
14
System.out.print(" ");
15
} else if (board[x][y] == Color.RED) {
16
System.out.print("r");
17
} else {
18
System.out.print("w");
19
}
20
}
21
System.out.println("");
22
}
23
System.out.print(" ");
24
for (byte x = 0; x < 7; x++) {
25
System.out.print(x);
26
}
27
}
28
}
29
30