C D E G I M N P R S T W

C

Car - class Car.
This class represents a car that is trying to find its way through a city.
Car() - Constructor for class Car
 
cars - Variable in class City
 
chooseBestDirection() - Method in class Car
Decides which direction this car prefers to move (NORTH, EAST, SOUTH, or WEST).
chooseSecondBestDirection() - Method in class Car
Decides which direction this car would like to move (NORTH, EAST, SOUTH, or WEST) if it can't have its first choice of direction.
city - Variable in class Car
 
City - class City.
This class represents a city with a well laid-out (rectangular) traffic grid.
City(int, int, int) - Constructor for class City
Creates a city with the given numberOfRows, numberOfColumns, and numberOfCars.
column - Variable in class Car
 

D

decideDestination() - Method in class Car
Chooses a destination for this car that isn't too close to its starting position.
destinationColumn - Variable in class Car
 
destinationRow - Variable in class Car
 
direction - Variable in class Car
 

E

EAST - Variable in class Car
 

G

getInt(String) - Static method in class City
Converts a String to an int.
getNumberOfColumns() - Method in class City
Returns the number of columns in this city.
getNumberOfRows() - Method in class City
Returns the number of rows in this city.

I

isAtDestination() - Method in class Car
Returns true if this car has reached its destination, false otherwise.
isOccupied(int, int) - Method in class City
Returns true if there is a car in the given row and column of this city, and false otherwise.

M

main(String[]) - Static method in class City
Simulates the traffic in a city.

N

NORTH - Variable in class Car
 
numberOfCars - Variable in class City
 
numberOfColumns - Variable in class City
 
numberOfRows - Variable in class City
 

P

placeCarAt(Car, int, int) - Method in class City
Puts the car at the given position in the city traffic grid.
placeNewCarInCity(City) - Method in class Car
Finds a random vacant spot in the city, and puts this new car in that location.
printTrafficGrid() - Method in class City
Prints the traffic grid for the city.

R

rand - Static variable in class Car
 
removeCarFrom(int, int) - Method in class City
Removes the car (assuming there is one) from the given position in the city traffic grid.
row - Variable in class Car
 
runSimulation() - Method in class City
As long as there are cars that have not yet reached their destinations, this method gives each car a chance to move, then prints the current traffic grid.

S

SOUTH - Variable in class Car
 

T

toString() - Method in class Car
Returns a short string representing the status of this car.
trafficGrid - Variable in class City
 
tryToMove() - Method in class Car
Finds in which direction this car prefers to move, and tries to move it in that direction.

W

WEST - Variable in class Car
 

C D E G I M N P R S T W