|
||||
| |
||||
| |
||||
Lab Quiz 1You are to do problem 5.15, page 267, of the text. Some rules for this lab quiz. First, you will need a main class that invokes the SteepleChaser class. The SteepleChaser class should have a runTheRace method that is invoked from the main class. This method is what actually runs the race, and of course it needs to be declared public in order to be invoked from the main class. Your SteepleChaser class must also have two private methods. One of these, moveToHurdle, should move the robot forward until it comes to the point where a hurdle exists. The second of these, jumpOverHurdle, should be passed a parameter that says how high to go up before going over the hurdle. These methods must be invoked in the runTheRace method. This is slightly fake in the following sense. You the programmer must hard code into the runTheRace method the number of spaces up to jump in order to go over a particular hurdle. Thus, you the human have to be able to look at the diagram and write the program accordingly. It would be less fake if the robot were able to sense the height of the hurdle and determine how how to jump without having that hard-coded in the program. When you create the city, create it with LabQuiz6.txt, as the text file defining the city and the race course. Your robot should start at location (4,1) and finish at location (4,16). Note that since there is no hurdle at the end of the race, moving to the end of the course after the last hurdle will take some special code. Upload your finished code to the departmental drop box as usual. |
|
|||



