Class ArithmeticProgression

java.lang.Object
com.zybooks.dsaj.design.Progression
com.zybooks.dsaj.design.ArithmeticProgression

public class ArithmeticProgression extends Progression
A class producing an arithmetic progression of the form start, start+step, start+2*step, ...
  • Field Details

    • increment

      protected long increment
      The increment between consecutive values of the progression
  • Constructor Details

    • ArithmeticProgression

      public ArithmeticProgression()
      Constructs progression 0, 1, 2, ...
    • ArithmeticProgression

      public ArithmeticProgression(long stepsize)
      Constructs progression 0, stepsize, 2*stepsize, ...
      Parameters:
      stepsize - the step size for the progression
    • ArithmeticProgression

      public ArithmeticProgression(long stepsize, long start)
      Constructs arithmetic progression with arbitrary start and increment.
      Parameters:
      stepsize - the step size for the progression
      start - the first value of the progression
  • Method Details

    • advance

      protected void advance()
      Adds the arithmetic increment to the current value.
      Overrides:
      advance in class Progression