Hello,
I'm trying complie this SortedList Program and List Java, but I'm alot errors. If someone can help with this, I really appricated.
Thanks
import java.util.Iterator;
/*
*
* SortedList.java
*
*/
public class SortedList<E extends Comparable<? super E>> extends List<E> {
private int size;
public SortedList(){
head = null;
size = 0;
}
public void insert(E data){
if(head == null){
head = new Node<E>(data);
size++;
} else {
Node<E> n = head;
while(n.next != null){
}
n.next = new Node<E>(data);
size++;
}
}
public void remove(E data) {
E.data = null;
if (head != null)
temp = head.data;
head = head.next;
return temp;
}
public E retrieve(int index){
if (index < size)
return size;
else
return null;
}
public boolean search(E data){
if(E.data < 1 || E.data > size())
return false;
Node<T> = head;
for(int i = 1; i < index; i++)
{
if(Node<T>.getNext() == null)
return false;
Node<T> = Node<T>.getNext();
}
Node<T>.setNext(Node<T>.getNext().getNext());
E.data--;
return true;
}
public Iterator<E> iterator() {
if (index < null || index > E.data)
throw new IndexofBoundException(Integers.toSTring(index));
return index;
else
return null;
}
}
/*
*
* List.java
*
*/
public abstract class List<E> implements Iterable<E> {
protected class Node<T> {
protected Node(T data) {
this.data = data;
}
protected T data;
protected Node<T> next;
}
public abstract void insert(E data);
public abstract void remove(E data);
public abstract E retrieve(int index);
//public abstract boolean search(E data);
protected Node<E> head;
}