|
||||||||||
| 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(City city,
Road road,
char direction,
int width,
int height,
int speed,
java.awt.Color color)
Construct all the components of 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. |
uwcse.graphics.Shape |
getBody()
Return the Shape that is the Car's body |
char |
getCurrentDirection()
Return the direction of travel of the Car |
Road |
getCurrentRoad()
Return the Road that the Car is currently traveling along. |
int |
getHeight()
Return the height of the Car's body |
int |
getSpeed()
Return the speed of the Car in pixels per clock tick |
int |
getWidth()
Return the width of the Car's body |
int |
getX()
Return the upper-left x-coordinate of the Car's body |
int |
getY()
Return the upper-left y-coordinate of the Car's body |
boolean |
hasCrashedInto(Car car)
Determine whether the Car's avatar has crashed into another Car. |
boolean |
isOnRoad(Road road)
Determine whether the Car's avatar is on the Road in question. |
boolean |
isTotaled()
Check whether this Car has been totaled. |
void |
removeFromWindow()
Remove the elements of this display object from the graphics window. |
void |
tick()
Perform all Car actions necessary per clock tick, assuming the Car hasn't been totaled. |
void |
totalCar(Car otherCar)
Total the car after an accident with another Car! Turn the body red, send it spinning out of control according to the direction and speed of the other Car, and set totaled to true. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Car(City city,
Road road,
char direction,
int width,
int height,
int speed,
java.awt.Color color)
city - the City 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 tick()
public Road getCurrentRoad()
public int getSpeed()
public char getCurrentDirection()
public int getX()
public int getY()
public int getWidth()
public int getHeight()
public uwcse.graphics.Shape getBody()
public boolean isOnRoad(Road road)
road - the Road being tested
public boolean hasCrashedInto(Car car)
car - the Car object being tested for intersection
public void totalCar(Car otherCar)
otherCar - Car with which this Car had its accidentpublic boolean isTotaled()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||