2. Using The Superclass
There was an issue discovered when testing the
WalkBot
prototypes. In some cases, the robots were incorrectly detecting their own legs as obstacles. To overcome this, we need to modify ouradjust_sensor
method to resetobstacle_found
toFalse
andstep_length
to5
while also using the original logic from the superclass. Here are the steps:
- Override the
adjust_sensor
method in theWalkBot
class by re-defining it in that class.- Call the superclass version of the method within
adjust_sensor
- Add a line of code to set
obstacle_found
toFalse
- Add a line of code to set
step_length
to5
This section refers to the correct instance variable to be changed: obstacle_found = False
Underneath that it refers to changing: obstacle_count = False
Within the
WalkBot
class, override theadjust_sensor
method to set theobstacle_count
instance variable toFalse
and set thestep_length
to5
in addition to the the original logic from the superclass.