Class Creature


  • public class Creature
    extends java.lang.Object
    • Field Detail

      • floor

        protected Floor floor
      • role

        protected Role role
      • timeUntilFree

        private int timeUntilFree
      • satiety

        private double satiety
      • name

        private java.lang.String name
    • Constructor Detail

      • Creature

        public Creature​(Role role)
        Creates person with role on random floor.
        Parameters:
        role - string role of person
    • Method Detail

      • doSomething

        public void doSomething()
        The function adjusts the desire of a person according to his satiety. If the child is hungry, an adult feeds him.
      • doAction

        private void doAction()
        The function looks for what kind of activity a person can do on the floor on which he is located. If there are no free activities on the floor, it changes the floor and searches again.
      • changeFloor

        public void changeFloor​(int i)
        Changes the floor the person is on.
        Parameters:
        i - floor number
      • changeFloorRandom

        public void changeFloorRandom()
        Randomly changes the floor a person is on.
      • continueAction

        public void continueAction()
        Continues the action of a person on a current device
      • isFree

        public boolean isFree()
        Checks if a person is currently free
        Returns:
        true if person is free false if person is busy
      • addTimeUntilFree

        public void addTimeUntilFree​(int add)
        Adds the number of iterations after which a person will be released.
        Parameters:
        add - number of iterations
      • decreasePersonTime

        public void decreasePersonTime()
        Decreases the number of iterations until the person is released.
      • getHelp

        public Creature getHelp​(AbstractActionDevice device)
        Finds an adult to help the child fix the device or eat.
        Parameters:
        device - device with which the child needs help.
        Returns:
      • release

        public void release()
        Frees the person from activity.
      • decreaseSatiety

        public void decreaseSatiety​(int difference)
        Reduces satiety.
        Parameters:
        difference - number of satiety units
      • eat

        public void eat()
        Increases a person's satiety.
      • action

        protected boolean action()
        The function assigns a device type to a person depending on his desire.
        Returns:
        true if there are suitable devices in the house. false if there are no suitable devices in the house.