I have made 3 classes below The problem is when I Implement a method last in the
ID: 3631347 • Letter: I
Question
I have made 3 classes below
The problem is when I Implement a method last in the class linked list that returns an iterator to the last item in the list.
I do not get it. I will reward with a good rate if someone helps me to achieve this
class list node <AnyType>
{
/ / Constructors
public list node (AnyType theElement)
{
this (theElement, null);
}
public list node (AnyType theElement, list node <AnyType> n)
{
item = theElement;
next = n;
}
public AnyType element;
public list node <AnyType> next;
}
public class linked list <AnyType>
{
/ **
* Return an iterator Representing the header node.
* /
public LinkedListIterator <AnyType> zeroth ()
{
return new LinkedListIterator <AnyType> (header);
}
}
public class LinkedListIterator <AnyType>
{
public AnyType retrieve ()
{
return isValid ()? current.element: null;
}
List node <AnyType> CurrentVersion / / Current position
}