import java.util.*;
/**
* IntListElem objects are elemets of a IntList list.
*
* Informatik II - FS2009
* Uebungsserie 5, Aufgaben 1-3
* @author Philipp Bolliger
**/
class IntListElem {
int value;
IntListElem next; //reference to the next element of the list
/**
* IntListElem constructor
*
* @param v value of the element being created
* @param e reference to the next element in the list
**/
public IntListElem( int v, IntListElem e ) {
value = v;
next = e;
}
} //end class IntListElement
/**
* The class IntList provides methods to create and use
* lists of integer.
*
* @author Silvia Santini
* Informatik II - SS2007
* Uebungsserie 5, Aufgaben 1-3
**/
public class IntList {
private IntListElem first; //reference to the first element of the list
/**
* Creates an empty list
*/
public IntList() {
first = null;
//other variables?
}
/**
* Test whether a list is empty or not
*
* @return true if list is empty, false otherwise
**/
public boolean empty() {
return first == null;
}
/**
* Adds an element at the top of the list
*
* @param i element to add
**/
public void addFirst( int i ) {
first = new IntListElem(i,first);
}
/**
* your text your text your text
*
* @param your text your text
**/
public void addLast( int i ) {
//add your code
}
/**
* your text your text your text
*
* @return text text text
**/
public int removeFirst() throws Exception {
//if( first == null ) {...}
//add your code
return -99999;
}
/**
* your text your text your text
**/
public int removeLast() {
//add your code
return -99999;
}
/**
* your text your text your text
**/
public void print() {
//add your code
}
/**
* your text your text your text
**/
public void addRandomElements( int n ) {
//add your code
}
/**
* your text your text your text
**/
public static IntList createRandomList( int n ) {
//add your code
return null; //change this line!!
}
/**
* your text your text your text
**/
public static int getNumLists() {
//add your code
return -99999;
}
/**
* your text your text your text
**/
public IntList sort() {
//add your code
return null;
}
/**
* your text your text your text
**/
private void insertSorted( int i ) {
//you might want to use this methode to implement the method sort()
}
/**
* your text your text your text
**/
public void sortSelf() {
//add your code
}
} // end class IntList