private static void setPosition(String position, Piece piece) { for (Position auxPos : Position.values()) { if (position.toLowerCase().equals(auxPos.getName().toLowerCase())) { piece.setX(auxPos.getX()); piece.setY(auxPos.getY()); } } }
// Calculate moves of each piece on the board private static void CalculateOutput(Board board) { for (Piece piece : board.getPieces()) { piece.ValidMoves(board); System.out.println("Valid Moves"); System.out.print( piece.getType().getName() + " on " + Position.getPosition(piece.getX(), piece.getY()) + " ["); // Iterator pattern from class Collections Iterator iterator = piece.getValidMoves().iterator(); while (iterator.hasNext()) { System.out.print((String) iterator.next()); if (iterator.hasNext()) System.out.print(", "); } System.out.println("]"); } }