Tips on writing the hurdler code

You should flesh out the tick() method so that it implements the following behavior:

  • If the Hurdler is at the finish line (facing the rightmost wall), it should do nothing.
  • If the Hurdler is facing a hurdle, it should jump the hurdle.
  • If the Hurdler has no obstacle in front of it, it should step forward one step.

As is often the case, the specification of the tick() method can be simplified with some auxiliary methods. You should define these methods as part of your solution:

  • The atFinishLine() method returns a boolean indicating whether the Hurdler is at the finish line. It can distinguish the finish line from a hurdle because the finish line is a wall that is more than one cell high. Think about what specific steps the buggle should take, in order to figure out whether it is facing a wall, i.e. is at finish line. Sensor methods, like atFinishLine(), should leave the position and heading of the buggle unchanged.
  • The jumpHurdle() method assumes the buggle is facing a hurdle and causes it to jump it. The buggle should end up facing EAST in the cell after the hurdle. This method does not call any of the other methods in the Hurdler class, it simply moves the buggle over a hurdle.