reset password
Author Message
chuckh
Posts: 12
Posted 08:47 May 06, 2016 |

Maybe I am overlooking where the copy constructor is but can someone let me know where that is? The instructions say to use the copy constructor provided to make a copy of the current board and save in the arraylist"

 

"

  • if the neighbouring square is valid (within the boundaries of the puzzle), make a copy of the current board (using the provided copy constructor), move the tile in that square to the empty square and add this copy of the board to the list of neighbours to be returned

"

rpuas
Posts: 29
Posted 22:32 May 06, 2016 |
Use this constructor... it returns a new PuzzleBoard with a copy of the tiles ArrayList

PuzzleBoard(PuzzleBoard otherBoard) {
    tiles = (ArrayList<PuzzleTile>) otherBoard.tiles.clone();
}