Class AbstractProgression

java.lang.Object
com.zybooks.dsaj.design.AbstractProgression

public abstract class AbstractProgression extends Object
Generates a simple progression. By default: 0, 1, 2, ...
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected long
    The value that will be reported by a call to nextValue().
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a progression starting at zero.
    AbstractProgression(long start)
    Constructs a progression with given start value.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    Advances the current value to the next value of the progression.
    long
    Returns the next value of the progression.
    void
    Utility that prints the next n values of the progression.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • current

      protected long current
      The value that will be reported by a call to nextValue().
  • Constructor Details

    • AbstractProgression

      public AbstractProgression()
      Constructs a progression starting at zero.
    • AbstractProgression

      public AbstractProgression(long start)
      Constructs a progression with given start value.
      Parameters:
      start - the first value in the progression
  • Method Details

    • nextValue

      public long nextValue()
      Returns the next value of the progression.
      Returns:
      the next value in the progression
    • printProgression

      public void printProgression(int n)
      Utility that prints the next n values of the progression.
      Parameters:
      n - the number of value to print
    • advance

      protected abstract void advance()
      Advances the current value to the next value of the progression.