anonymous
2012-02-07 18:28:26 UTC
int end_row); Its parameters represent a chess piece, its starting location on the chessboard, and the location of a potential
move. It will determine whether the piece, starting, and ending locations are valid, and whether the ending
location of the potential move represents a valid move for that type of piece from the starting location.
• The first parameter piece indicates the piece under consideration, using the following values:
1. An uppercase P indicates the piece is a pawn.
2. An uppercase R indicates the piece is a rook.
3. An uppercase B indicates the piece is a bishop.
4. An uppercase N indicates the piece is a knight.
15. An uppercase K indicates the piece is a king.
6. An uppercase Q indicates the piece is a queen.
• The second parameter start col is a character that represents the column of the piece’s starting position.
• The third parameter start row is an integer that represents the row of the piece’s starting position.
• The fourth parameter end col is a character that represents the column of the piece’s ending position.
• The fifth parameter end row is an integer that represents the row of the piece’s ending position.
The return values are this:
Your function will not produce any output, it will just return different values as described below after analyzing
the potential move:
1. Your function should return the value 0 if all of the parameters are valid, and the piece can legally move
from the starting position to the ending position, according to the rules in Section 4.
2. Your function should return the value −1 if the starting and ending position and piece are both valid, but
the piece in question cannot legally move from the starting position to the ending position, according to
the rules in the following subsection. This case includes when the starting and ending locations are the
same, since no piece can validly move to the same location it started from.
3. Your function should return the value −2 if the value of the parameter piece does not correctly indicate
one of the six piece types, as described above.
4. Your function should return the value −3 if the starting position is incorrect, in other words if the column
and row combination of the starting position does not represent a valid square on the chess board.
5. Your function should return the value −4 if the ending position is incorrect, in other words if the column
and row combination of the ending position does not represent a valid square on the chess board.
If the values of the parameters are such that the move would have more than one of the errors described,
your function can return the value for any of the applicable error conditions.