hts.StevenWood.com

[ Last Page ]

Karel 10

Complete the following in class or for homework.

Use the concept of inheritance taught in class to create a child class of the RobotSE, named RacerRobot. This robot is going to run a race with 3 hurdles. At each hurdle, the robot must jump over the hurdle (see the diagram). The race will be exactly 6 strides long.

This child class should have a method called raceStride. The raceStride method should move the robot forward when it can, otherwise jump over one hurdle only when it must. The method jumpHurdle() can be a helper method called by the raceStride method.

In jumping a hurdle, use helper methods named jumpUp and glideDown (recall that helper methods are declared private, since they are only used within the class itself).

Use the city file Athens.txt. Start your robot at avenue 1, street 6 facing East, with no things in its backpack, as shown (the robot is the red arrowhead). The robot will run the hurdle race by calling the raceStride method 6 times.

Do NOT hand in your work unless other instructions were given.

    
[Last Page]
All material on this site is copyright © 1997- by Steven Wood or as credited. All right reserved. Use of this site indicates you agreement with the  terms of use.
Send comments or questions to about this page.
Every attempt has been made to credit work under copyright. If there are any claims that copyright has been missed please contact the .
+SDG+