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

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 value

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!