|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--City
This class models all of the stationary objects in our scene.
| Constructor Summary | |
City(Director director,
int ewRoads,
int nsRoads,
int windowHeight,
int windowWidth)
Create a new City object with the specified number of East-West and North-South Roads, keeping in mind the space limitations of the provided GWindow dimensions. |
|
| Method Summary | |
void |
addTo(uwcse.graphics.GWindow g)
Add the elements of this display object to the graphics window. |
Road |
getEWRoad(int number)
Retrieve the Road in the specified position in the East-West roadList. |
Road |
getNSRoad(int number)
Retrieve the Road in the specified position in the North-South roadList. |
int |
getNumberOfEWRoads()
Return the number of East-West roads. |
int |
getNumberOfNSRoads()
Return the number of North-South roads. |
Road |
getRoadAboutToIntersect(Car car)
Scan all of the Roads lying perpendicular to the given Car's path to see if the Car will be at or inside any of those intersections at the end of its next movement. |
TrafficLight |
getTrafficLightAtIntersectionOf(Road road1,
Road road2)
Return the TrafficLight object that exists at this intersection, or null if no light at that intersection can be found (perhaps because the intersection does not exist). |
void |
removeFromWindow()
Remove the elements of this display object from the graphics window. |
void |
tick()
Tell each TrafficLight in the City to count one clock tick. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public City(Director director,
int ewRoads,
int nsRoads,
int windowHeight,
int windowWidth)
director - the Director object, which must be referenced to access the CarsewRoads - the integer number of East-West Roads in the CitynsRoads - the integer number of North-South Roads in the CitywindowHeight - the integer height of the GWindowwindowWidth - the integer width of the GWindow| 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 Road getEWRoad(int number)
number - the integer index of the desired element in the Road list
public Road getNSRoad(int number)
number - the integer index of the desired element in the Road list
public int getNumberOfEWRoads()
public int getNumberOfNSRoads()
public TrafficLight getTrafficLightAtIntersectionOf(Road road1,
Road road2)
road1 - one of the roads making up the intersectionroad2 - the other road making up the intersection
public void tick()
public Road getRoadAboutToIntersect(Car car)
car - the Car object being tested for near-intersection with the Roads
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||