I have a class called Board that contains the following
public class Board {
protected Piece[][] GameBoard = new Piece[8][8];
ArrayList<Move> BlackBoardmoves = new ArrayList<Move>();
ArrayList <Move> WhiteBoardmoves = new ArrayList<Move>();
I want to create an entirely new object of Board that has 2 entirely seperate ArrayLists I've been reading about how to do this for days and I've tried various methods like implementing cloning or serializable. I've read that the clone interface is broken and that using serializable is going to be much slower so I decided to write my own copy method
void copy(Board c)
{
for(int i =0; i<8; i++)
{
for(int j=0; j<8; j++)
{
this.GameBoard[i][j] = c.GameBoard[i][j];
}
}
for(int i=0 ;i<c.BlackBoardmoves.size(); i++)
{
this.BlackBoardmoves.add(c.BlackBoardmoves.get(i));
}
for(int i=0 ;i<c.WhiteBoardmoves.size(); i++)
{
this.WhiteBoardmoves.add(c.WhiteBoardmoves.get(i));
}
}
What I'm currently doing when creating each new object is this
Board obj2 = new Board();
obj2.copy(obj1);
This is a very small part of my project so I've been stuck on it for days and really can't afford to spend more time stuck in this. Thank you a lot:)