/// <summary> /// Generate a copy of the board /// </summary> /// <returns>A copy of this board</returns> public IBoard Copy() { Checkerboard board = new Checkerboard(); System.Array.Copy(this.pieces, board.pieces, this.pieces.Length); return(board); }
/// <summary> /// Copy the state of the given checker board /// </summary> /// <param name="board">The checker board to copy</param> public void Copy(Checkerboard board) { if (board == null) { throw new ArgumentNullException("board"); } System.Array.Copy(board.pieces, this.pieces, this.pieces.Length); }
/// <summary> /// Copy the state of the given board /// </summary> /// <param name="board">The board to copy</param> public void Copy(IBoard board) { if (board.Size != this.Size) { throw new ArgumentException("Incompatable board sizes"); } Checkerboard checkerboard = board as Checkerboard; if (checkerboard != null) { // Copy board in an optimized fashion this.Copy(checkerboard); } else { for (int i = 1; i <= pieces.Length; i++) { this[i] = board[i]; } } }
/// <summary> /// Copy - копия /// Copy the state of the given board /// Скопировать состояние данной доски /// </summary> /// <param name="board"> /// The board to copy /// Доска для копирования /// </param> public void Copy(IBoard board) { if (board.Size != this.Size) { throw new ArgumentException("Incompatable board sizes");//Несовместимые размеры платы } Checkerboard checkerboard = board as Checkerboard; if (checkerboard != null) { // Copy board in an optimized fashion // Копируем доску оптимизированным способом this.Copy(checkerboard); } else { for (int i = 1; i <= pieces.Length; i++) { this[i] = board[i]; } } }