I need help solving this Java problem, any advice, tips, or code would be greatly appreicated. Thanks.
Begin by writing an abstract class named Sequence. The Sequence class contains the following abstract methods:
public abstract boolean hasNext()
Returns true if the sequence contains another term after the current term. This is not a mutator.
public abstract Object next()
Returns the current term of the sequence and advances the sequence. This is a mutator.
public abstract Object peek()
Returns the current term of the sequence without advancing the sequence. This is not a mutator.
public abstract Object nth(int n)
Returns the nth term of the sequence or -1 if this term does not exist. Use 0 origin indexing. This is not a mutator.
public abstract void reset( )
Resets the current term back to the first term of the sequence. This is a mutator.
To complete this level you will now write three classes that extend the Sequence class(either directly or through a chain of intermediate classes – do what you want). We will check to make sure your three class definitions do rely on the Sequence class. Each of these classes should have a null constructor (a constructor that takes no arguments).
(1) PositiveIntegers enumerates all the positive integers starting with 1.
(2) EvenIntegers enumerates all the positive even integers starting with 2.
(3) AllPrimes enumerates all the prime numbers starting with 2.
(4) Add a second constructor to each of the above classes. This constructor takes a single argument of the same type as the class being defined, and makes a copy of that argument. Note: If the sequence in the argument has been advanced to the nth term, make sure the copy you create has been advanced to the nth term as well.