To Teach
Problems:
Variable Declaration
Link L1 = new Link();
Link L2 = new Link();
Link L3 = new Link();
Link L4 = new Link();
Link L5 = new Link();
Take Actions
L1.move(1);
L2.turn(RIGHT);
L2.move(1);
L3.turn(LEFT);
L3.move(1);
L4.turn(LEFT);
L4.turn(LEFT);
L4.move(1);
If Statements
L1.move(1);
if (L1.isBlocked()){
L1.turn(RIGHT);
}
L1.move(1);
Functions and Loops
public static void look(Link L){
if (L.isBlocked()){
L1.turn(RIGHT);
}
forward(L);
}
public static void forward(Link L) {
if (!L.isBlocked()){
L.move(1);
}
}
look(L1);
Advanced Actions
public void forward(Link L){
/* movement code */
activate(L);
/* forward_after */
}
public void activate(Link L){
if (L.isInteractive()){
L1.activate();
}
return;
}
Solutions
Code: github.com/ghmeier/fableofzelma