Class Lives

java.lang.Object
core.Lives

public class Lives extends Object
Implementation of the Lives feature.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Lives(int x)
    Standard constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns if the current number of lives is above 0.
    void
    Changes the number of remaining lives by x.
    int
    Returns the current number of lives.
    int
    Returns the max number of lives.
    void
    Resets the current number of lives to the max value.
    void
    setMax(int numMax)
    Changes the max value of lives.
    Returns a formatted string containing current lives.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Lives

      public Lives(int x)
      Standard constructor.
      Parameters:
      x - number of starting lives.
  • Method Details

    • getMax

      public int getMax()
      Returns the max number of lives.
    • getCurrent

      public int getCurrent()
      Returns the current number of lives.
    • changeCurrent

      public void changeCurrent(int x)
      Changes the number of remaining lives by x.
      Parameters:
      x - value added to current lives.
    • resetCurrent

      public void resetCurrent()
      Resets the current number of lives to the max value.
    • setMax

      public void setMax(int numMax)
      Changes the max value of lives.
      Parameters:
      numMax - new max number of lives.
    • alive

      public boolean alive()
      Returns if the current number of lives is above 0.
    • toString

      public String toString()
      Returns a formatted string containing current lives. Returns a ending message if current lives are 0.
      Overrides:
      toString in class Object