Programming Language Concepts Jan-Apr 2009 Assignment 2 Due Monday, 23 February, 2009 Define a Java class LinearList that can store an arbitrarily long list of *distinct* integers. You should implement LinearList as a linked list in which the nodes of the list are not publicly visible. The class should support the following methods: public int size(); // return the list size public int indexOf(int elem); // return the index of the first occurrence of elem in the list, // return -1 if elem is not in the list public int remove(int index); // remove and return the indexth element, elements with higher // index have their index reduced by 1 // // if index < 0 or index >= size, remove the first/last // element, respectively public void add(int elem) throws DuplicateValueException; // insert elem as the end of the list, if it does not already // appear in the list // // throw DuplicateValueException if the element already occurs public String toString(); // output list elements from beginning to end public MyIterator getIterator(): // returns an object that implements the interface // MyIterator, given below, pointing to the first value in // the list. public interface MyIterator{ public abstract boolean hasNext(); // returns true if the iteration has more elements. public abstract int next() throws NoMoreValuesException; // returns the next element in the iteration // // Throw NoMoreValuesException if iteration has no more elements } Note: You also have to define the exception classes DuplicateValueException and NoMoreValuesException in your code. ======================================================================