public class Robot { public static final int HALLWAY_LENGTH = 10; public static final int NORTH = 1; public static final int SOUTH = -NORTH; private int dir = NORTH, pos = 1; public void step() { if (wallInFront()) System.err.println("Ouch, I bumped my head!"); else pos += dir; } public void step(int n) { while (n != 0) { step(); n--; } } public boolean wallInFront() { return false; } public void turnAround() { dir = -dir; } public String toString() { String orientation = "north"; if (dir == SOUTH) orientation = "south"; return "I am at position " + pos + " facing " + orientation + "."; } }