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

public enum State extends Enum<State>
Represents the three state which Pacman can have. The behaviour are defined as "NORMAL", "EATER" and "INVINCIBLE".
  • "NORMAL" - Its the most frequent state. Its duration is Integer.MAX_VALUE.
  • "EATER" - Pacman can kill ghosts. It has a duration of 30, the same as the ghosts's frightened behaviour.
  • "INVINCIBLE" - Pacman cannot be killed by ghosts, but it does not kill ghosts either. Duration = 5.
  • 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
    State when Pacman eats an energizer and is able to eat/kill ghosts.
    State when Pacman has been killed, and it cannot neither be killed nor kill ghosts.
    State in which Pacman is usually.
  • Field Summary

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

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

    Modifier and Type
    Method
    Description
    int
    Gets the duration of the state.
    Returns a String with information of the State.
    Format: STATE:stateDuration
    Example: "INVINCIBLE:5"

    Hint: Remember that toString() is already coded in Object.
    static State
    Returns the enum constant of this class with the specified name.
    static State[]
    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

    • NORMAL

      public static final State NORMAL
      State in which Pacman is usually.
    • EATER

      public static final State EATER
      State when Pacman eats an energizer and is able to eat/kill ghosts.
    • INVINCIBLE

      public static final State INVINCIBLE
      State when Pacman has been killed, and it cannot neither be killed nor kill ghosts.
  • Field Details

    • duration

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

    • State

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

    • values

      public static State[] 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 State 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 state.
      Returns:
      duration of the state.
    • toString

      public String toString()
      Returns a String with information of the State.
      Format: STATE:stateDuration
      Example: "INVINCIBLE:5"

      Hint: Remember that toString() is already coded in Object.
      Overrides:
      toString in class Enum<State>
      Returns:
      State:stateDuration