Goal:
Iteration Abstraction, Immutability, JUnit.
Provide in immutable version, ImmutableIterator,
of Liskov's version of the Iterator interface.
You need only consider the next()
and hasNext() methods.
Note that hasNext() is fine as it is,
but that you will need to split the next()
method into two new methods:
public Object nextObject() throws NoSuchElementException public ImmutableIterator nextIterator() throws NoSuchElementException
Provide a sample implementation of this interface
on the Poly class from Liskov (ie the immutable version).
The behavior should be similar to Liskov's terms() method.
Provide appropriate JUnit tests.