MazeRunningKarel
Retired DISLab
/** * File: MazeRunningKarel.java * --------------------------- * This program extends Karel so that it can solve a maze * using the right-hand rule. */ import stanford.karel.*; public class MazeRunningKarel extends SuperKarel { public void run() { while (noBeepersPresent()) { turnRight(); while (frontIsBlocked()) { turnLeft(); } move(); } } public static void main(String[] args) { String[] newArgs = new String[args.length + 1]; System.arraycopy(args, 0, newArgs, 0, args.length); newArgs[args.length] = "code=" + new SecurityManager(){ public String className() { return this.getClassContext()[1].getCanonicalName(); } }.className(); SuperKarel.main(newArgs); } }