Class Environment

  • All Implemented Interfaces:
    IEnvironment

    public class Environment
    extends java.lang.Object
    implements IEnvironment
    The environment object for non distributed applications.
    • 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.
    • Constructor Detail

      • Environment

        public Environment()
        Create a new environment.
    • 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 interface IEnvironment
        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 interface IEnvironment
        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 interface IEnvironment
        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.