-
Notifications
You must be signed in to change notification settings - Fork 1
/
PortalsMove
24 lines (23 loc) · 925 Bytes
/
PortalsMove
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package Updated;
class PortalsMoves
{
// A CheckersMove object represents a move in the game of Checkers.
// It holds the row and column of the piece that is to be moved
// and the row and column of the square to which it is to be moved.
// (This class makes no guarantee that the move is legal.)
int fromRow, fromCol; // Position of piece to be moved.
int toRow, toCol; // Square it is to move to.
PortalsMoves(int r1, int c1, int r2, int c2) {
// Constructor. Just set the values of the instance variables.
fromRow = r1;
fromCol = c1;
toRow = r2;
toCol = c2;
}
boolean isJump() {
// Test whether this move is a jump. It is assumed that
// the move is legal. In a jump, the piece moves two
// rows. (In a regular move, it only moves one row.)
return (fromRow - toRow == 2 || fromRow - toRow == -2);
}
} // end class CheckersMove.