Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Progression Class From the theory book: // The Progression class public class Progression { protected long current; public Progression() { this(0); } public Progression(long

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

=+applying to all or most employers and employees?

Answered: 1 week ago

Question

=+associated with political parties and if so, which ones? Are

Answered: 1 week ago