Class Robot

java.lang.Object
  extended by java.lang.Thread
      extended by objectdraw.ActiveObject
          extended by 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

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  objectdraw.DrawingCanvas mycanvas
           
(package private)  Image myImage
           
(package private)  objectdraw.VisibleImage myVimage
           
protected  Vector<Obstacle> obstacles
           
protected static double PAUSETIME
           
protected static int SIZE
           
protected  double xSpeed
           
protected  double ySpeed
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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
Constructor Detail

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 me
canvas - in which it will be drawn
point - my starting position
obstacles - the obstacles in my pit
Method Detail

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()