|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.collegeboard.gridworld.world.World<T>
public class World<T>
A world is the mediator between a grid and the GridWorld GUI.
copyright© 2005 Cay S. Horstmann (http://horstmann.com)
Constructor Summary | |
---|---|
World()
|
|
World(Grid<T> g)
|
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. |
T |
remove(Location loc)
Removes an occupant from a given location. |
void |
setGrid(Grid<T> newGrid)
Sets the grid managed by this world. |
void |
setMessage(String newMessage)
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public World()
public World(Grid<T> g)
Method Detail |
---|
public void show()
public Grid<T> getGrid()
public void setGrid(Grid<T> newGrid)
newGrid
- the new gridpublic void setMessage(String newMessage)
newValue
- the new messagepublic String getMessage()
public void step()
public boolean locationClicked(Location loc)
loc
- the grid location that the user selected
public void add(T occupant)
occupant
- the occupant to addpublic void add(Location loc, T occupant)
loc
- the locationoccupant
- the occupant to addpublic T remove(Location loc)
loc
- the location
public void addGridClass(String className)
className
- the name of the grid classpublic void addOccupantClass(String className)
className
- the name of the occupant classpublic Set<String> getGridClasses()
public Set<String> getOccupantClasses()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |