Package com.zybooks.dsaj.design
Class ArithmeticProgression
java.lang.Object
com.zybooks.dsaj.design.Progression
com.zybooks.dsaj.design.ArithmeticProgression
A class producing an arithmetic progression of the form start, start+step, start+2*step, ...
-
Field Summary
Modifier and TypeFieldDescriptionprotected long
The increment between consecutive values of the progressionFields inherited from class com.zybooks.dsaj.design.Progression
current
-
Constructor Summary
ConstructorDescriptionConstructs progression 0, 1, 2, ...ArithmeticProgression
(long stepsize) Constructs progression 0, stepsize, 2*stepsize, ...ArithmeticProgression
(long stepsize, long start) Constructs arithmetic progression with arbitrary start and increment. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
advance()
Adds the arithmetic increment to the current value.Methods inherited from class com.zybooks.dsaj.design.Progression
nextValue, printProgression
-
Field Details
-
increment
protected long incrementThe 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 progressionstart
- the first value of the progression
-
-
Method Details
-
advance
protected void advance()Adds the arithmetic increment to the current value.- Overrides:
advance
in classProgression
-