COMPUTER SCIENCE Summer 2006
Unit 1, Lab05 Shuttle Run
Create the file Racer.java. The beginning of the code for class Racer is on page One-21. You need to define:
A constructor Racer. This takes one argument (or parameter) which represents the street value (y value) the Racer begins on. Note that this constructor in Racer calls the constructor in Athlete with the command super. The constructor in Athlete needs all four parameters, not just the y value.
the code for jumpRight(). Pseudocode is provided.
the code for sprint. This uses a "for" loop and moves the Racer n times.
the code for put. This also uses a "for" loop. This command puts down n beepers.
the code for pick. This also uses a "for" loop. This command picks up n beepers.
Create Lab05.java. Use World.readWorld() to read "shuttle" and World.setSize() to make the world 10 by 10.
Use Racer racername = new Racer(yvalue) three times to create three racers.
Define a class method public static void runTheRace(racer argument) for each racer to accomplish its tasks.
Each racer picks up an entire pile at once (with your newly defined "pick" function), brings the beepers back to start, drops them off, then goes and gets the next pile.