Class RandomRobot
java.lang.Object
java.lang.Thread
objectdraw.ActiveObject
Robot
RandomRobot
- All Implemented Interfaces:
- Runnable
public class RandomRobot
- extends Robot
RandomRobot moves around, bouncing around the rectangle.
When it hits an obstacle it backs off to its previous position
Then it randomly:
reverses its x speed, or
reverses its y speed, or
reverses both x and y speeds
- Version:
- 21x06
- Author:
- Rhys Price Jones
Constructor Summary |
RandomRobot(Image me,
objectdraw.DrawingCanvas canvas,
objectdraw.Location point,
Vector<Obstacle> obstacles)
Constructor for objects of class RandomRobot
like all Robots, just calls parent constructor
and starts |
Method Summary |
void |
handleObstacles(objectdraw.Location lastLoc)
handleObstacles
what to do if we hit one of the obstacles |
Methods inherited from class objectdraw.ActiveObject |
defer, getTime, pause, pause, pause, yield |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString |
RandomRobot
public RandomRobot(Image me,
objectdraw.DrawingCanvas canvas,
objectdraw.Location point,
Vector<Obstacle> obstacles)
- Constructor for objects of class RandomRobot
like all Robots, just calls parent constructor
and starts
handleObstacles
public void handleObstacles(objectdraw.Location lastLoc)
- handleObstacles
what to do if we hit one of the obstacles
- Specified by:
handleObstacles
in class Robot
- Parameters:
lastLoc
- -- the most recent good position I was in