Question
The Progression Class From the theory book: // The Progression class public class Progression { protected long current; public Progression() { this(0); } public Progression(long
The Progression Class From the theory book:
// The Progression class public class Progression {
protected long current;
public Progression() { this(0); }
public Progression(long start) { current = start; }
public long nextValue() { long answer = current; advance(); return answer; }
protected void advance() { current++; }
public void printProgression(int n) { System.out.print(nextValue()); for (int j = 1; j
####################################################################
// The Arithmetic Progression class public class ArithmeticProgression extends Progression { protected long increment;
public ArithmeticProgression() { this(1, 0); }
public ArithmeticProgression(long stepsize) { this(stepsize, 0); }
public ArithmeticProgression(long stepsize, long start) { super(start); increment = stepsize; }
protected void advance() { current += increment; } }
####################################################################
// The Geometric Progression class public class GeometricProgression extends Progression { protected long base;
public GeometricProgression() { this(2, 1); }
public GeometricProgression(long b) { this(b, 1); }
public GeometricProgression(long b, long start) { super(start); base = b; }
protected void advance() { current *= base; } }
Q1. Redesign the Progression class (covered in your theory book) to be abstract and generic, producing a sequence of values of generic type T, and supporting a single constructor that accepts an initial value. Note: Any subclass inherited from this class will remain as non-generic classes. Q2. Use a solution to Q1 to create a new progression class for which each value is the square root of the previous value, represented as a Double. You should include a default constructor that has 65,536 as the first value and a parametric constructor that starts with a specified number as the first valueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started