Design a chess game. Basics of a chess game was explained and a player could be human or AI?

Submitted by: Administrator
Follow-up questions:
* What are the main objects?
* How do the main objects interact with each other?
* Which object or objects own the current game state information?
* Implement the method to move a piece to another position on the board. method must communicate if the move is legal or not.
* How do you test the move piece method?

Chessboard: contains a matrix of chess pieces objects
Player: contains a list of references to his/her active chesspieces
Chess piece: contanis color or player, and what type of piece is it (tower, horse...)

boolean canMove(pieceType, start_x_pos, end_x_pos, start_y_pos, end_y_pos){
if (type equals horse){
canMoveHorse (pieceType, start_x_pos, end_x_pos, start_y_pos, end_y_pos);
}
else if (type equals horse){...}
...
}

test1: the piece is at the indicated position
test2: the piece has the same color at before it was moved
test3: if there was another piece at the end position, now it has been removed from the chessboard and from its player's list
test4: if it is a queen, tower, ... check that before the movement there wasn't any other piece in the path
test5: check that the other pieces are at the same places where they were before the movement
Submitted by: Administrator

Read Online Apple Job Interview Questions And Answers