Class FeelingRobot
java.lang.Object
|
+----Robot
|
+----BouncingRobot
|
+----FeelingRobot
- public class FeelingRobot
- extends BouncingRobot
FeelingRobot is a BouncingRobot except that it uses sensors
to detect the wall before actually hitting it. (Hopefully,
this will protect the stepper from stress.)
-
back
-
-
front
-
-
FeelingRobot(Stepper, Color, Sensor, Sensor)
- FeelingRobot now also accepts Sensor objects for the
whiskers and tail, which are the front and back
sensors, respectively.
-
act()
- This overrides BouncingRobots act().
front
protected Sensor front
back
protected Sensor back
FeelingRobot
public FeelingRobot(Stepper s,
Color c,
Sensor whiskers,
Sensor tail)
- FeelingRobot now also accepts Sensor objects for the
whiskers and tail, which are the front and back
sensors, respectively.
act
public void act()
- This overrides BouncingRobots act(). Here, right before
we try to move, we check the sensors and adjust the direction
accordingly if the sensors sense anything.
- Overrides:
- act in class BouncingRobot