controller

Class ButtonListener

    • Constructor Detail

      • ButtonListener

        public ButtonListener(OceanInterface model,
                      OceanGUIInterface view)
        Instantiates a new button listener.
        Parameters:
        model - the model
        view - the view
    • Method Detail

      • actionPerformed

        public void actionPerformed(java.awt.event.ActionEvent e)
        This method gets an ActionEvent (with button was pressed) and execute the specific code.
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
        Parameters:
        e - the action event that provides the info which button was pressed.
      • createObject

        private void createObject(java.lang.String type,
                        java.lang.String name,
                        int maximumAge,
                        int[] position)
                           throws java.lang.Exception
        Parameters:
        type - a String describing the type of OceanObject to create
        name - a String containing the name for the object
        maximumAge - an integer specifying the maximum age
        position -
        Throws:
        java.lang.Exception - Create an new OceanObject, by type.
      • getMaximumAge

        private int getMaximumAge()
        Gets the maximum age.
        Returns:
        the maximum age
      • getName

        private java.lang.String getName()
        Returns:
        The String from the name field.
      • getTypeOfObject

        private java.lang.String getTypeOfObject()
        Gets the type of object.
        Returns:
        the type of object
      • getXPosition

        private int getXPosition()
        Gets the x position.
        Returns:
        the x position
      • getYPosition

        private int getYPosition()
        Gets the y position.
        Returns:
        the y position
      • load

        private void load(java.io.File nameLoad,
                java.lang.String pathLoad)
        This method loads an ocean from a file.
        Parameters:
        nameLoad - a String containig the file name.
        pathLoad - a String containig the path to the file.
      • printBubbleThreadStates

        private void printBubbleThreadStates()
        Prints out the state of each bubble generator thread, for debugging purposes.
      • save

        private void save(java.io.File nameSave,
                java.lang.String pathSave)
        This method saves an ocean to a file.
        Parameters:
        nameSave - a String containig the file name.
        pathSave - a String containig the path to the file.
      • showOverview

        private void showOverview()
        Print out a little ocean overview.