File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,23 @@ public class Board implements Grid
9
9
private int nextPlayer ;
10
10
private int [][] playerAtPosition ;
11
11
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
+ }
12
29
13
30
public Board (int rowsP , int colsP )
14
31
{
Original file line number Diff line number Diff line change @@ -75,4 +75,6 @@ public interface Grid
75
75
public int getWinningPlayer ();
76
76
77
77
public void undo ();
78
+
79
+ public Grid clone ();
78
80
}
You can’t perform that action at this time.
0 commit comments