com.collegeboard.gridworld.grid
Interface World<T>

All Known Implementing Classes:
com.collegeboard.gridworld.gui.AbstractWorld, ActorWorld

public interface World<T>

A world is the mediator between a grid and the GridWorld GUI.

copyright© 2005 Cay S. Horstmann (http://horstmann.com)


Method Summary
 void add(Location loc, T occupant)
          Adds an occupant at a given location
 void add(T occupant)
          Adds an occupant at a random location
 void addGridClass(String className)
          Adds a class to be shown in the "Set grid" menu.
 void addOccupantClass(String className)
          Adds a class to be shown when clicking on an empty cell
 Grid<T> getGrid()
          Gets the grid managed by this world.
 Set<String> getGridClasses()
          Gets a set of grid classes that should be used by the world frame for this world.
 String getMessage()
          Gets the message to be displayed in the world frame above the grid.
 Set<String> getOccupantClasses()
          Gets a set of occupant classes that should be used by the world frame for this world.
 boolean locationClicked(Location loc)
          This method is called when the user clicks on a location in the WorldFrame.
 void setGrid(Grid<T> newGrid)
          Sets the grid managed by this world.
 void setMessage(String newValue)
          Sets the message to be displayed in the world frame above the grid.
 void show()
          Constructs and shows a frame for this world.
 void step()
          This method is called when the user clicks on the step button, or when run mode has been activated by clicking the run button.
 

Method Detail

getGrid

Grid<T> getGrid()
Gets the grid managed by this world.

Returns:
the grid

setGrid

void setGrid(Grid<T> newGrid)
Sets the grid managed by this world.

Parameters:
newGrid - the new grid

setMessage

void setMessage(String newValue)
Sets the message to be displayed in the world frame above the grid.

Parameters:
newValue - the new message

getMessage

String getMessage()
Gets the message to be displayed in the world frame above the grid.

Returns:
the message

step

void step()
This method is called when the user clicks on the step button, or when run mode has been activated by clicking the run button.


locationClicked

boolean locationClicked(Location loc)
This method is called when the user clicks on a location in the WorldFrame.

Parameters:
loc - the grid location that the user selected

add

void add(T occupant)
Adds an occupant at a random location

Parameters:
occupant - the occupant to add

add

void add(Location loc,
         T occupant)
Adds an occupant at a given location

Parameters:
loc - the location
occupant - the occupant to add

addGridClass

void addGridClass(String className)
Adds a class to be shown in the "Set grid" menu.

Parameters:
className - the name of the grid class

addOccupantClass

void addOccupantClass(String className)
Adds a class to be shown when clicking on an empty cell

Parameters:
className - the name of the occupant class

getGridClasses

Set<String> getGridClasses()
Gets a set of grid classes that should be used by the world frame for this world.

Returns:
the set of grid class names

getOccupantClasses

Set<String> getOccupantClasses()
Gets a set of occupant classes that should be used by the world frame for this world.

Returns:
the set of occupant class names

show

void show()
Constructs and shows a frame for this world.