Class Robot
java.lang.Object
java.lang.Thread
objectdraw.ActiveObject
Robot
- All Implemented Interfaces:
- Runnable
- Direct Known Subclasses:
- ClingerRobot, RandomRobot, StupidRobot
public abstract class Robot
- extends objectdraw.ActiveObject
Robot moves around a bunch of obstacles.
-- including its bounding rectangle, which is made up of four filledRects
starts at Location passed in to constructor
abstract method handleObstacles() -- used to modify motion if obstacle hit
- Version:
- 21x06
- Author:
- Rhys Price Jones
Constructor Summary |
Robot(Image portrait,
objectdraw.DrawingCanvas canvas,
objectdraw.Location point,
Vector<Obstacle> obstacles)
Constructor for objects of class Robot
note -- do not follow the textbook advice to end the constructor with
start()
It makes it difficult to extend the class
Since this is abstract, that would be a disaster! |
Method Summary |
abstract void |
handleObstacles(objectdraw.Location lastLoc)
abstract handleObstacles
what to do if we hit one of the obstacles |
void |
run()
Method run -- invoked by start() |
void |
setSpeed()
setSpeed
used to set initial speed components xSpeed and ySpeed
must make assignment to xSpeed and ySpeed |
void |
step()
|
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 |
mycanvas
protected objectdraw.DrawingCanvas mycanvas
myImage
Image myImage
myVimage
objectdraw.VisibleImage myVimage
obstacles
protected Vector<Obstacle> obstacles
PAUSETIME
protected static final double PAUSETIME
- See Also:
- Constant Field Values
SIZE
protected static final int SIZE
- See Also:
- Constant Field Values
xSpeed
protected double xSpeed
ySpeed
protected double ySpeed
Robot
public Robot(Image portrait,
objectdraw.DrawingCanvas canvas,
objectdraw.Location point,
Vector<Obstacle> obstacles)
- Constructor for objects of class Robot
note -- do not follow the textbook advice to end the constructor with
start()
It makes it difficult to extend the class
Since this is abstract, that would be a disaster!
- Parameters:
portrait
- an image of mecanvas
- in which it will be drawnpoint
- my starting positionobstacles
- the obstacles in my pit
handleObstacles
public abstract void handleObstacles(objectdraw.Location lastLoc)
- abstract handleObstacles
what to do if we hit one of the obstacles
- Parameters:
lastLoc
- -- the most recent good position I was in
run
public void run()
- Method run -- invoked by start()
- Specified by:
run
in interface Runnable
- Overrides:
run
in class Thread
setSpeed
public void setSpeed()
- setSpeed
used to set initial speed components xSpeed and ySpeed
must make assignment to xSpeed and ySpeed
step
public void step()