import info.gridworld.actor.Bug; import info.gridworld.grid.Location; public class DashBug extends Bug { private int segmentLength; // the number of flowers in each dash private int steps; // the number of steps in the current dash public DashBug(int length) { setDirection(Location.EAST); steps = 0; segmentLength = length; } public void act() { if (steps < segmentLength && canMove()) { move(); steps++; } else if (steps == segmentLength && canMove()) { Location currentLoc = getLocation(); int currentColumn = currentLoc.getCol(); int currentRow = currentLoc.getRow(); Location nextLoc = new Location(currentRow, currentColumn + segmentLength); moveTo(nextLoc); // or typed as one line of code...... // moveTo(new Location(getLocation().getRow(), getLocation().getCol() + segmentLength)); steps = 0; } else { removeSelfFromGrid(); } } }