Class BouncingRobot
java.lang.Object
|
+----Robot
|
+----BouncingRobot
- public class BouncingRobot
- extends Robot
BouncingRobot is a Robot which bounces when it hits a wall.
i.e., if it can't step in a certain direction, it changes direction
-
movingForward
-
-
BouncingRobot(Stepper, Color)
-
-
act()
- BouncingRobot overrides the act() method.
movingForward
protected boolean movingForward
BouncingRobot
public BouncingRobot(Stepper s,
Color c)
act
public void act()
- BouncingRobot overrides the act() method.
Instead of moving forward all the time, the robot moves
forward until it hits a wall and cannot step. Then,
it starts moving backward until it hits the wall, then
it starts moving forward again, ... ad nauseam.
- Overrides:
- act in class Robot