Exercises


  1. Create a new parameterized collection typea Ring. A Ring is a circular list that maintains knowledge of a current element. A client can retrieve and remove the current element. The Ring must support advancing or backing up the current pointer by one position. The method add adds an element after the current element. The Ring class should support client iteration through all elements, starting at the current pointer, using for-each. The Ring class should throw appropriate exceptions on any operation that is invalid because the ring is empty.

    Do not use another data structure to store the ring (e.g., a java.util.LinkedList). Create your own link structure using a nested node class. Each node, or entry, should contain three things: the data element added, a reference to the next node in the circle, and a reference to the previous node in the circle.



Agile Java. Crafting Code with Test-Driven Development
Agile Javaв„ў: Crafting Code with Test-Driven Development
ISBN: 0131482394
EAN: 2147483647
Year: 2003
Pages: 391
Authors: Jeff Langr

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net