Class Button

java.lang.Object
ch.epfl.cs107.play.window.Button
All Implemented Interfaces:
Serializable

public final class Button extends Object implements Serializable
Contains the current and previous states of a button.
See Also:
  • Constructor Details

    • Button

      public Button(boolean previous, boolean current, boolean isLastPressed)
      Creates a new button state.
      Parameters:
      previous - (boolean): previous state
      current - (boolean): current state
      isLastPressed - (boolean): indicate if the button is the last button pressed
    • Button

      public Button(boolean previous, boolean current)
      Creates a new button state.
      Parameters:
      previous - (boolean): previous state
      current - (boolean): current state
    • Button

      public Button(boolean current)
      Creates a new button state.
      Parameters:
      current - (boolean): previous and current state
  • Method Details

    • isDown

      public boolean isDown()
      Returns:
      (boolean): whether the button is currently pressed
    • isUp

      public boolean isUp()
      Returns:
      (boolean): whether the button is currently released
    • wasDown

      public boolean wasDown()
      Returns:
      (boolean): whether the button was released, regardless of current state
    • wasUp

      public boolean wasUp()
      Returns:
      (boolean): whether the button was pressed, regardless of current state
    • isPressed

      public boolean isPressed()
      Returns:
      (boolean): whether the button was just pressed
    • isLastPressed

      public boolean isLastPressed()
      Returns:
      (boolean): whether the button is the last button pressed
    • isReleased

      public boolean isReleased()
      Returns:
      (boolean): whether the button was just released
    • updated

      public Button updated(boolean next)
      Creates an new state, given this state.
      Parameters:
      next - (boolean): the new state, used to compute new transition
      Returns:
      (Button) a new button state, not null
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object