Class Environment
- java.lang.Object
-
- jadex.bdi.examples.cleanerworld_classic.Environment
-
- All Implemented Interfaces:
IEnvironment
public class Environment extends java.lang.Object implements IEnvironment
The environment object for non distributed applications.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.MapagesThe cleaner ages.protected java.util.ListcleanersThe cleaners.protected booleandaytimeThe daytime.protected static EnvironmentinstanceThe singleton.SimplePropertyChangeSupportpcsThe helper object for bean events.protected java.util.ListstationsThe charging stations.protected java.util.ListwastebinsThe waste bins.protected java.util.ListwastesThe wastes.
-
Constructor Summary
Constructors Constructor Description Environment()Create a new environment.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChargingStation(Chargingstation station)Add a charging station.voidaddCleaner(Cleaner cleaner)Add a cleaner.voidaddPropertyChangeListener(PropertyChangeListener listener)Add a PropertyChangeListener to the listener list.voidaddWaste(Waste waste)Add a piece of waste.voidaddWastebin(Wastebin wastebin)Add a wastebin.voidclear()Clear the environment.static voidclearInstance()Clear the singleton instance.booleandropWasteInWastebin(Waste waste, Wastebin wastebin)Drop a piece of waste.intgetAge(Cleaner cleaner)Get the age of a cleaner.Chargingstation[]getChargingstations()Get all charging stations.Cleaner[]getCleaners()Get all cleaners.VisiongetCompleteVision()Get the complete vision.booleangetDaytime()Get the daytime.static EnvironmentgetInstance()Get the singleton.VisiongetVision(Cleaner cleaner)Get the current vision.protected WastebingetWastebin(Wastebin wb)Get a wastebin for a template.WastebingetWastebin(java.lang.String name)Get a wastebin for a name.Wastebin[]getWastebins()Get all wastebins.Waste[]getWastes()Get all wastes.booleanpickUpWaste(Waste waste)Try to pick up some piece of waste.voidremoveCleaner(Cleaner cleaner)Remove a cleaner.voidremovePropertyChangeListener(PropertyChangeListener listener)Remove a PropertyChangeListener from the listener list.voidremoveWaste(Waste waste)Remove a piece of waste.voidsetDaytime(boolean daytime)Set the daytime.
-
-
-
Field Detail
-
instance
protected static Environment instance
The singleton.
-
daytime
protected boolean daytime
The daytime.
-
cleaners
protected java.util.List cleaners
The cleaners.
-
wastes
protected java.util.List wastes
The wastes.
-
wastebins
protected java.util.List wastebins
The waste bins.
-
stations
protected java.util.List stations
The charging stations.
-
ages
protected java.util.Map ages
The cleaner ages.
-
pcs
public SimplePropertyChangeSupport pcs
The helper object for bean events.
-
-
Method Detail
-
getInstance
public static Environment getInstance()
Get the singleton.- Returns:
- The environment.
-
clearInstance
public static void clearInstance()
Clear the singleton instance.
-
getVision
public Vision getVision(Cleaner cleaner)
Get the current vision.- Specified by:
getVisionin interfaceIEnvironment- Parameters:
cleaner- The cleaner.- Returns:
- The current vision, null if failure.
-
pickUpWaste
public boolean pickUpWaste(Waste waste)
Try to pick up some piece of waste.- Specified by:
pickUpWastein interfaceIEnvironment- Parameters:
waste- The waste.- Returns:
- True if the waste could be picked up.
-
dropWasteInWastebin
public boolean dropWasteInWastebin(Waste waste, Wastebin wastebin)
Drop a piece of waste.- Specified by:
dropWasteInWastebinin interfaceIEnvironment- Parameters:
waste- The piece of waste.wastebin- The waste bin.
-
getWastebin
protected Wastebin getWastebin(Wastebin wb)
Get a wastebin for a template.- Returns:
- The wastebin.
-
getCompleteVision
public Vision getCompleteVision()
Get the complete vision.- Returns:
- The current vision, null if failure.
-
getDaytime
public boolean getDaytime()
Get the daytime.- Returns:
- The current vision.
-
setDaytime
public void setDaytime(boolean daytime)
Set the daytime.- Parameters:
daytime- The daytime.
-
addCleaner
public void addCleaner(Cleaner cleaner)
Add a cleaner.- Parameters:
cleaner- The cleaner.
-
removeCleaner
public void removeCleaner(Cleaner cleaner)
Remove a cleaner.- Parameters:
cleaner- The cleaner.
-
addWaste
public void addWaste(Waste waste)
Add a piece of waste.- Parameters:
waste- The new piece of waste.
-
removeWaste
public void removeWaste(Waste waste)
Remove a piece of waste.- Parameters:
waste- The piece of waste.
-
addWastebin
public void addWastebin(Wastebin wastebin)
Add a wastebin.- Parameters:
wastebin- The new waste bin.
-
addChargingStation
public void addChargingStation(Chargingstation station)
Add a charging station.- Parameters:
station- The new charging station.
-
getWastes
public Waste[] getWastes()
Get all wastes.- Returns:
- All wastes.
-
getWastebins
public Wastebin[] getWastebins()
Get all wastebins.- Returns:
- All wastebins.
-
getChargingstations
public Chargingstation[] getChargingstations()
Get all charging stations.- Returns:
- All stations.
-
getCleaners
public Cleaner[] getCleaners()
Get all cleaners.- Returns:
- All cleaners.
-
getWastebin
public Wastebin getWastebin(java.lang.String name)
Get a wastebin for a name.- Returns:
- The wastebin.
-
clear
public void clear()
Clear the environment.
-
getAge
public int getAge(Cleaner cleaner)
Get the age of a cleaner.- Returns:
- The age.
-
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.
-
-