import java.util.Iterator; import java.util.NoSuchElementException; public class List<E> { private E[] listArray = (E[]) new Object[300]; private int size = 0; private int currentPosition=0; /** * Inserts the specified element at the beginning of this list. * * @param element element to be appended to this list */ public void addFirst(E element) { for (int i=size; i>0; i--) { listArray[size] = listArray[size-1]; } listArray[0] = element; size++; } /** * Appends the specified element to the end of this list. * * @param element element to be appended to this list */ public void addLast(E element) { for (int j=size; j>0; j++) { listArray[size] =listArray[size-1]; } listArray[size] = element; size++; } /** * Removes all of the elements from this list. The list will be * empty after this call returns. */ public void clear() { for(int x=0; x<size;x++) { listArray[x]=null; } size=0; } /** * Returns <code>true</code> if this list contains the specified * element. More formally, returns <code>true</code> if and only * if this list contains at least one element <code>e</code> such * that (<code>o==null ? e--null : o.equals(e)</code>). * * @param o element whose presence in this list is to be tested * @return <code>true</code> if this list contains the specified element */ public boolean contains(Object o) { throw new java.lang.RuntimeException("Method not implemented"); } /** * Returns the first element from this list. * * @return the first element from this list * @throws NoSuchElementException if this list is empty */ public E getFirst() { return listArray[0]; } /** * Returns the last element from this list. * * @return the last element from this list * @throws NoSuchElementException if this list is empty */ public E getLast() { return listArray[size-1]; } /** * Returns the element at the specified position in this list. * * @param index index of the element to return * @return the element at the specified position in this list * @throws IndexOutOfBoundsException if the index is out of range ( * <code>index < 0 || index >= size()</code>) */ public E get(int index) { for(index=0;index >=size;index++) return listArray[index]; throw new java.lang.RuntimeException("Method not implemented"); } /** * Returns the index of the first occurrence of the specified element in * this list, or -1 if this list does not contain the element. * * @param o element to search for * @return the index of the first occurrence of the specified element in * this list, or -1 if this list does not contain the element */ public int indexOf(Object o) { throw new java.lang.RuntimeException("Method not implemented"); } /** * Returns <code>true</code> if this list contains no elements. * * @return <code>true</code> if this list contains no elements. */ public boolean isEmpty() { return size == 0; } /** * Removes and returns the first element from this list. * * @return the first element from this list * @throws NoSuchElementException if this list is empty */ public E removeFirst() throws NoSuchElementException { throw new java.lang.RuntimeException("Method not implemented"); } /** * Removes and returns the last element from this list. * * @return the last element from this list * @throws NoSuchElementException if this list is empty */ public E removeLast() { throw new java.lang.RuntimeException("Method not implemented"); } /** * Returns the number of elements in this list. * * @return the number of elements in this list */ public int size() { throw new java.lang.RuntimeException("Method not implemented"); } /** * Returns an iterator over the elements in this list in proper sequence. * * @return an iterator over the elements in this list in proper sequence. */ public Iterator<E> iterator() { public boolean hasNext() { if (size > currentPosition) return true; else return false; } public Object next() { return listArray[currentPosition]; } public void remove(){ throw new java.lang.RuntimeException("Method not implemented"); } }