|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectbecker.robots.Sim
public abstract class Sim
A Sim is an element of the robot city which participates in the simulation, namely a Thing (such as Walls, Lights), a Robot, or an Intersection.
Since this class is abstract it cannot be instantiated; only subclasses may be instantiated. This class exists to ensure that basic services required for the simulation are present and to provide common implementations for required several services.
| Constructor Summary | |
|---|---|
Sim(City aCity,
int aStreet,
int anAvenue,
Direction orientation,
Icon anIcon)
Construct a new Sim. |
|
| Method Summary | |
|---|---|
City |
getCity()
Returns a reference to this sim's city. |
Color |
getColor()
Get this sim's color. |
Icon |
getIcon()
Return the icon used to display the visible characteristics of this sim, based on the sim's current state. |
protected abstract Intersection |
getIntersection()
Return the intersection where this Sim is located. |
protected void |
keyTyped(char key)
This method is called when a key is typed and keyboard input is directed to karel's world (the map, as opposed to a different window or the controls for karel's world). |
void |
notifyObservers()
Notify any observers of this Sim (for instance, the user interface) that it has changed. |
protected void |
notifyObservers(Object changeInfo)
Notify any observers of this Sim (for instance, the user interface) that it has changed. |
void |
setColor(Color color)
Set this sim's color. |
void |
setIcon(Icon theIcon)
Set the icon used to display this sim. |
String |
toString()
Print this object represented as a string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Sim(City aCity,
int aStreet,
int anAvenue,
Direction orientation,
Icon anIcon)
aCity - The city in which the Sim will exist.aStreet - The Sim's initial street within the city.anAvenue - The Sim's initial avenue within the city.orientation - The Sim's initial orientation. One of
{Direction.NORTH, EAST, SOUTH, WEST, NORTHWEST, NORTHEAST,
SOUTHWEST, SOUTHEAST}.anIcon - The icon to use to display this Sim.| Method Detail |
|---|
public void setColor(Color color)
color - The new color for this Sim.public Color getColor()
public Icon getIcon()
public void setIcon(Icon theIcon)
theIcon - The new icon to use in displaying this Sim.public void notifyObservers()
protected void notifyObservers(Object changeInfo)
changeInfo - Any extra information required by the observer.protected abstract Intersection getIntersection()
protected void keyTyped(char key)
key - The key that was typed.public String toString()
toString in class Objectpublic City getCity()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||