Skip to content

Commit c1f358a

Browse files
authored
Update Board.java
1 parent 8620604 commit c1f358a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Diff for: src/connect4/connectFour/Board.java

+17
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ public class Board implements Grid
99
private int nextPlayer;
1010
private int[][] playerAtPosition;
1111
private ArrayList<Integer> undoList;
12+
13+
public Grid clone() {
14+
Board ret = new Board(rows, cols);
15+
16+
ret.undoList = new ArrayList<Integer>(undoList);
17+
ret.playerAtPosition = new int[rows][cols];
18+
19+
for(int i = 0; i < rows; i++) {
20+
for(int j = 0; j < cols; j++) {
21+
ret.playerAtPosition[i][j] = playerAtPosition[i][j];
22+
}
23+
}
24+
25+
ret.nextPlayer = nextPlayer;
26+
27+
return ret;
28+
}
1229

1330
public Board(int rowsP, int colsP)
1431
{

0 commit comments

Comments
 (0)