Bill Teter
Office:          149 Redcay
Telephone:    2782
Office Hours:  Tuesday, Thursday 9:00-12:00

email:  william.teter@plattsburgh.edu

       

 

lab 14 (exam)  the linked ring class

In this lab you will make a generic ring class.  The objects in this class are in a circular structure.  So long as the ring is not empty there is a "current" object.  The Ring class should be generic.  The methods the ring class supports are:

public void add(AT x)
    // If the ring is empty x is current.  Otherwise, x is added to the ring after current.  Current does not change.

public int size()
    // returns the number of objects in the ring.

public AT next()
    // the object after current becomes the new current and the new current is returned.

Extra credit

public void remove()
    // the current node is removed, the node after current (if any) becomes the new current.

You can use my test programs. There are two, Test.java and TestExtraCredit.java.  They are in:

/home/teterwa/public/csc223/lab14

Requirements:

Use a linked implementation with one field that references the current node.  You will need a Node inner class and the node class will have a data field and a next field to reference the next node.