import java.util.*; /** * This class generates all legal moves. * There are two fields, moves and jumps. * moves is a LinkedList of elements of type aMove. * jumps is a LinkedList of elements of type LinkedLists of Integers * (the representation for jump). * If there is at least one jump, then the jump must be taken. * Therefore, if there is at least one jump, then move = null. * If there are no legal jumps, then jump = null. */ public class Mover{ public LinkedList moves; public LinkedList jumps; /** * Both moves and jumps are set to null. */ Mover(){ moves = new LinkedList(); jumps = new LinkedList(); moves = null; jumps = null; } /** * Returns moves. */ public LinkedList Moves(){ return moves; } /** * Returns jumps */ public LinkedList Jumps(){ return jumps; } /** * Given a CheckerBoard and a player *(indicated by either 'p'. 'P', 'o', or 'O'), * sets moves to be all legal moves and * jumps to be all legal jumps. * Note the comment at the beginning of this classes documentation. */ public void GetMoves(CheckerBoard b, char player){ jumps = Jump.GetJumps(b,player); // if (jumps.size()==0){ if(jumps==null){ //jumps = null; moves = aMove.GetMoves(b,player); } else{ if(jumps.size()!=0) {moves = null;} else {jumps =null; moves = aMove.GetMoves(b,player);}} } /** * Given a CheckerBoard and a position on the board, * sets moves to be all legal moves and * jumps to be all legal jumps. * Note the comment at the beginning of this classes documentation. */ public void GetMoves(CheckerBoard b, int pos){ jumps = Jump.GetJumps(b,pos); if (jumps == null){ moves = aMove.GetMoves(b,pos); } else{ if(jumps.size()!=0){ moves = null; } else{moves = aMove.GetMoves(b,pos);} } } }