//Name David Willmore import edu.pace.World; import edu.pace.

Robot;

Date 2 Dec. 2011

public class Racer extends Athlete { public Racer(int y) { super(1,y,World.EAST,World.INFINITY); } // Racer public void jumpRight() { turnLeft(); move(); turnRight(); move(); turnRight(); move(); turnLeft(); } // jumpRight() public void jumpLeft() { turnRight(); move(); turnLeft(); move(); turnLeft(); move(); turnRight(); } // jumpLeft() public void sprint(int n) { for(int k = 1; k <= n; k++) move(); } // sprint public void pickPile(int n) { for(int k = 1; k<= n; k++) pickBeeper(); } // put public void putPile(int n) { for(int k = 1; k <= n; k++) putBeeper(); } // pick } // class

//Name David Willmore import edu.pace.World; import edu.pace.Robot;

Date 2 Dec. 2011

public class Lab05 { public static void shuttle(Racer arg) { arg.move();arg.jumpRight();arg.sprint(2); arg.pickPile(7);arg.sprint(2); arg.pickPile(5);arg.sprint(2); arg.pickPile(3);arg.turnAround(); arg.sprint(6);arg.jumpLeft();arg.sprint(1); arg.putPile(15);arg.turnAround();arg.sprint(1); } // shuttle public static void main(String[] args) { World.readWorld("shuttle"); World.setSize(10, 10); World.setSpeed(15); Racer ted = new Racer(1); Racer kim = new Racer(4); Racer jen = new Racer(7); shuttle(ted); shuttle(kim); shuttle(jen);

} // main } // class

Sign up to vote on this title
UsefulNot useful