Jadex 0.96

jadex.examples.garbagecollector
Class Environment

java.lang.Object
  extended by jadex.examples.garbagecollector.Environment

public class Environment
extends Object

The environment.


Field Summary
static String BURNER
          The world object/agent types.
static String COLLECTOR
           
static String DOWN
           
static String GARBAGE
           
static String LEFT
           
 SimplePropertyChangeSupport pcs
          The helper object for bean events.
static String RIGHT
           
static String UP
          The directions.
 
Constructor Summary
Environment(int size)
          Create an environment.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 void addWorldObject(String type, String name, Position pos)
          Add an object to the environment.
 void burn(String name)
          Burn a piece of garbage.
static void clearInstance()
          Clear the singleton instance.
 void drop(String name)
          Drop a piece of garbage.
 Position getBurnerPosition()
          Get the position of a burner.
 String[] getGarbages(Position pos)
          Get all world objects of a position.
 int getGridSize()
          Get the grid size.
static Environment getInstance(String type, String name)
          Get a singleton instance.
 Position getPosition(String name)
          Get the position of an object.
 void go(String name, String dir)
          Go in a specific direction.
 boolean hasGarbage(String name)
          Test if an agent has garbage.
 boolean isBurnerPresent(Position pos)
          Is a burner on the map.
 boolean isDirty(Position pos)
          Test if a position is dirty.
 boolean pickup(String name)
          Pickup a piece of garbage.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UP

public static final String UP
The directions.

See Also:
Constant Field Values

DOWN

public static final String DOWN
See Also:
Constant Field Values

LEFT

public static final String LEFT
See Also:
Constant Field Values

RIGHT

public static final String RIGHT
See Also:
Constant Field Values

BURNER

public static final String BURNER
The world object/agent types.

See Also:
Constant Field Values

COLLECTOR

public static final String COLLECTOR
See Also:
Constant Field Values

GARBAGE

public static final String GARBAGE
See Also:
Constant Field Values

pcs

public SimplePropertyChangeSupport pcs
The helper object for bean events.

Constructor Detail

Environment

public Environment(int size)
Create an environment.

Method Detail

getInstance

public static Environment getInstance(String type,
                                      String name)
Get a singleton instance.


clearInstance

public static void clearInstance()
Clear the singleton instance.


addWorldObject

public void addWorldObject(String type,
                           String name,
                           Position pos)
Add an object to the environment.


go

public void go(String name,
               String dir)
Go in a specific direction.


drop

public void drop(String name)
Drop a piece of garbage.

Parameters:
name - The name of the agent that want to drop.

pickup

public boolean pickup(String name)
Pickup a piece of garbage.

Parameters:
name - The name of the agent that want to pick up.

burn

public void burn(String name)
Burn a piece of garbage.

Parameters:
name - The name of the agent that want to drop.

isDirty

public boolean isDirty(Position pos)
Test if a position is dirty.

Parameters:
pos - The position.
Returns:
True, if one or more pieces of garbage are present.

hasGarbage

public boolean hasGarbage(String name)
Test if an agent has garbage.

Parameters:
name - The agent name.
Returns:
True, if has garbage.

getPosition

public Position getPosition(String name)
Get the position of an object.

Parameters:
name - The name of the agent.
Returns:
The position.

getGridSize

public int getGridSize()
Get the grid size.

Returns:
The size of the grid.

getBurnerPosition

public Position getBurnerPosition()
Get the position of a burner.

Returns:
The (first found, hack) position of a burner.

isBurnerPresent

public boolean isBurnerPresent(Position pos)
Is a burner on the map.

Parameters:
pos - The position to test.
Returns:
True, if a burner is present.

getGarbages

public String[] getGarbages(Position pos)
Get all world objects of a position.

Parameters:
pos - The position.
Returns:
All objects at the position.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.

Parameters:
listener - The PropertyChangeListener to be added.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

Parameters:
listener - The PropertyChangeListener to be removed.

Jadex 0.96

Submit a bug or feature
For further API reference and developer documentation, see the Jadex User Guide and the Jadex Tutorial. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, and working code examples.

Copyright (C) 2002-2007 Lars Braubach, Alexander Pokahr - University of Hamburg. Use is subject to license terms.