// Overview: The class captures the attributes and functionalities of // a move in the game of checkers. The attributes include the position // of a particular piece (respresented as a row and column identifier) // and the destination of the move (also represented as a row and a // column). // Assumptions: It is assumed that the move is legal. public class CheckersMove{ // Attributes private int fromRow,fromCol; // Position of piece to be moved. private int toRow, toCol; // Square it is to move to. // Methods // Constructor: Just set the values of the instance variables. CheckersMove(int r1, int c1, int r2, int c2) { fromRow = r1; fromCol = c1; toRow = r2; toCol = c2; } // end CheckersMove() public boolean isJump() { // Test whether this move is a jump. The difference between // that and a normal move is, in a jump, the piece moves two // rows. return (fromRow - toRow == 2 || fromRow - toRow == -2); } //end isJump() // The accessors // Get the row identifier of the current position public int getfromRow(){ return fromRow; } //end getfromRow // Get the column identifier of the current position public int getfromCol(){ return fromCol; } // end getfromCol() // Get the row identifier of the destination position public int gettoRow(){ return toRow; } // end gettoRow() // Get the column identifier of the destination position public int gettoCol(){ return toCol; } // end gettoCol() } // end class CheckersMove.