Enum Class Behaviour

java.lang.Object
java.lang.Enum<Behaviour>
edu.uoc.pacman.model.entities.characters.ghosts.Behaviour
All Implemented Interfaces:
Serializable, Comparable<Behaviour>, Constable

public enum Behaviour extends Enum<Behaviour>
Behaviour defines the different behaviour which a ghost can be in. The behaviour are defined as "CHASE", "SCATTER", "FRIGHTENED" and "INACTIVE".
  • "CHASE" - Behaviour where the ghosts chase Pacman. Has a duration of 20.
  • "FRIGHTENED" - Behaviour where the ghosts are frightened and confused. It has a duration of 30.
  • "SCATTER" - Behaviour where the ghosts run home (scatter position). IT has a duration of 10.
  • "INACTIVE" - Behaviour where the ghosts don't do anything and Pacman cannot kill them.
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Behaviour where the ghosts chase Pacman.
    Behaviour where the ghosts are frightened and confused.
    Behaviour where the ghosts don't do anything and Pacman cannot kill them.
    Behaviour where the ghosts run home (scatter position).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    Stores the duration of the behaviour.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Behaviour(int duration)
    Constructor with arguments.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the duration of the behaviour.
    Returns a String with information of the Behaviour.
    static Behaviour
    Returns the enum constant of this class with the specified name.
    static Behaviour[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • CHASE

      public static final Behaviour CHASE
      Behaviour where the ghosts chase Pacman. Has a duration of 20
    • FRIGHTENED

      public static final Behaviour FRIGHTENED
      Behaviour where the ghosts are frightened and confused. It has a duration of 30
    • SCATTER

      public static final Behaviour SCATTER
      Behaviour where the ghosts run home (scatter position). IT has a duration of 10.
    • INACTIVE

      public static final Behaviour INACTIVE
      Behaviour where the ghosts don't do anything and Pacman cannot kill them.
  • Field Details

    • duration

      private final int duration
      Stores the duration of the behaviour.
  • Constructor Details

    • Behaviour

      private Behaviour(int duration)
      Constructor with arguments.
      Parameters:
      duration - Value to set to the behaviour.
  • Method Details

    • values

      public static Behaviour[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Behaviour valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getDuration

      public int getDuration()
      Gets the duration of the behaviour.
      Returns:
      duration of the behaviour.
    • toString

      public String toString()
      Returns a String with information of the Behaviour. Format: BEHAVIOUR:behaviourDuration Example: "CHASE:20" Hint: Remember that toString() is already coded in Object.
      Overrides:
      toString in class Enum<Behaviour>
      Returns:
      BEHAVIOUR:behaviourDuration