CSE100
Project #0
Due: 2008-09-30 11:59:00PM PDT.
Generic Linked List
In this first assignment, you will implement a linked list class using Java
generics. Your class must support the following operations:
-
void insertDataAt( Generic newObject, int index )
-
Adds newObject to the list at the specified index. So, if the index
is 3, the new object is inserted after the 3rd object already in the
list. If the index is out of bounds, throw the appropriate
exception.
-
Generic getAt( int index )
-
return a reference to the object at the specified index.
-
void deleteAt( int index )
-
removes the object at the specified index. Again, throw the
appropriate exception if the index is out of bounds.
-
int length( void )
-
return the length of the list
-
void printAll( void )
-
iterate over the list and print each object to System.out by using its
.toString() method.
For example, the following code:
MyList<String>
list = new MyList<String>();
list.insertDataAt(new
String("is"), 0);
list.insertDataAt(new
String("CSE 100"), 0);
list.insertDataAt(new
String("awesome."), 2);
list.printAll();
list.insertDataAt(new
String("really"), 2);
list.printAll();
should display:
CSE100 is
awesome.
CSE100 is really
awesome.
For an introduction to Java generics, see the tutorial at:
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
Guidelines
- You may work alone or in a team of 2 people (for all future assignments, you must work in teams of 2 people).
- Include a file named README which includes your names.
- For the assignment, do not use any of the provided classes/interfaces in java collections. You should write the class for the node (just the two private data members, etc) and for the list (uses the node) yourself.
- Your code should be thoroughly documented with javadoc. (we will be more lenient with this part for #0 than with future assignments)
Turning in
When your program is finished, create a tar file including your source code and
class files by running:
tar czvf
LASTNAME.tar.gz *.java *.class README
Then, submit your tar file by running:
turnin -c cs100f -p p0
LASTNAME.tar.gz