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


Variable Index

 o movingForward

Constructor Index

 o BouncingRobot(Stepper, Color)

Method Index

 o act()
BouncingRobot overrides the act() method.

Variables

 o movingForward
 protected boolean movingForward

Constructors

 o BouncingRobot
 public BouncingRobot(Stepper s,
                      Color c)

Methods

 o 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