Class Environment
- java.lang.Object
-
- jadex.bdiv3.examples.cleanerworld.world.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.Map
ages
The cleaner ages.protected java.util.List
cleaners
The cleaners.protected boolean
daytime
The daytime.protected static Environment
instance
The singleton.jadex.commons.SimplePropertyChangeSupport
pcs
The helper object for bean events.protected java.util.List
stations
The charging stations.protected java.util.List
wastebins
The waste bins.protected java.util.List
wastes
The 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 void
addChargingStation(Chargingstation station)
Add a charging station.void
addCleaner(Cleaner cleaner)
Add a cleaner.void
addPropertyChangeListener(jadex.commons.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.void
addWaste(Waste waste)
Add a piece of waste.void
addWastebin(Wastebin wastebin)
Add a wastebin.void
clear()
Clear the environment.static void
clearInstance()
Clear the singleton instance.boolean
dropWasteInWastebin(Waste waste, Wastebin wastebin)
Drop a piece of waste.int
getAge(Cleaner cleaner)
Get the age of a cleaner.Chargingstation[]
getChargingstations()
Get all charging stations.Cleaner[]
getCleaners()
Get all cleaners.Vision
getCompleteVision()
Get the complete vision.boolean
getDaytime()
Get the daytime.static Environment
getInstance()
Get the singleton.Vision
getVision(Cleaner cleaner)
Get the current vision.protected Wastebin
getWastebin(Wastebin wb)
Get a wastebin for a template.Wastebin
getWastebin(java.lang.String name)
Get a wastebin for a name.Wastebin[]
getWastebins()
Get all wastebins.Waste[]
getWastes()
Get all wastes.boolean
pickUpWaste(Waste waste)
Try to pick up some piece of waste.void
removeCleaner(Cleaner cleaner)
Remove a cleaner.void
removePropertyChangeListener(jadex.commons.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.void
removeWaste(Waste waste)
Remove a piece of waste.void
setDaytime(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 jadex.commons.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:
getVision
in 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:
pickUpWaste
in 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:
dropWasteInWastebin
in 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(jadex.commons.beans.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(jadex.commons.beans.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.
-
-