|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--Car
This class models a car in our scene.
| Constructor Summary | |
Car(Director director,
Road road,
char direction,
int width,
int height,
int speed,
java.awt.Color color)
Construct the Rectangle avatar for the Car given the Road it is on and the direction of travel. |
|
| Method Summary | |
void |
addTo(uwcse.graphics.GWindow g)
Add the elements of this display object to the graphics window. |
void |
advance()
This method moves the car a little bit. |
boolean |
carIsOnRoad(Road roadToCheck)
This method checks whether the Car is on a given Road by checking its upper left corner against the boundaries of the Road. |
Road |
getCrossRoad()
This method checks the coordinates of all Roads (other than the one the Car is intended to be traveling on) to see if the Car also happens to be on one of those Roads. |
Road |
getCurrentRoad()
Return the Road that the Car is currently traveling along. |
void |
removeFromWindow()
Remove the elements of this display object from the graphics window. |
void |
speedUpIfInNewIntersection()
This method asks getCrossRoad() if the Car is in any intersection. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Car(Director director,
Road road,
char direction,
int width,
int height,
int speed,
java.awt.Color color)
director - the Director object that will need to be queried by the Carroad - the Road on which the car is to be traveling initiallydirection - the initial cardinal direction of the car's travel ('N','E','S','W')width - width of the car's Rectangleheight - height of the car's Rectanglespeed - number of pixels to move the Car per framecolor - color of the Car| Method Detail |
public void addTo(uwcse.graphics.GWindow g)
addTo in interface uwcse.animation.Propg - the graphics window to usepublic void removeFromWindow()
removeFromWindow in interface uwcse.animation.Proppublic void advance()
public boolean carIsOnRoad(Road roadToCheck)
roadToCheck - the Road to be checked
public Road getCrossRoad()
public void speedUpIfInNewIntersection()
public Road getCurrentRoad()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||