S
CpSc 210, Section 1
Assignment 6
27 February 2002
Due: Thursday, March 7 at 11:59 p.m.
Not accepted late.
Total point value of assignment: 100 points
This assignment is to be done INDIVIDUALLY.
Assignment: Design and implement a class, ExtendedList, which must
be stored in a file named ExtendedList.java. (Failure to name a file
or class correctly is an automatic 20 point deduction.) This assignment
extends Bailey's SinglyLinkedList and reverses a list. Use the following
structure for your program
import structure.SinglyLinkedList;
import structure.SinglyLinkedListElement;
public class ExtendedList extends SinglyLinkedList
{
public ExtendedList ( )
{
super ( ); // calls constructor of SinglyLinkedList class
}
public SinglyLinkedListElement previous
( SinglyLinkedListElement current )
// pre: current is not null
// post: if current references first SinglyLinkedListElement in List
// or if this list is empty, null is returned.
// Otherwise, a reference to the SinglyLinkedListElement
// preceding the SinglyLinkedListElement referenced by
// current is returned.
public void reverse ( )
// post: this list is reversed (destroying previous list in process)
public static void main ( String [ ] args )
// test driver for ExtendedList class
{
ExtendedList myList = new ExtendedList ( );
// etc.
}
}
Bailey's code for SinglyLinkedList can be found at
http://www.mhhe.com/engcs/compsci/bailey/source/SinglyLinkedList.java
You may add any private methods you wish. All SinglyLinkedList methods
and instance variables will be inherited from Bailey's SinglyLinkedList class,
so you may use both instance variables and methods as if you were writing
code in the SinglyLinkedList class.
Note that you must declare list variables of type ExtendedList in your
test driver. If you declare variables of type SinglyLinkedList, these
variables cannot use the previous and reverse methods.
Output:
Print your name, the assignment number, and a short description
of the assignment to the screen.
Your main method should test reverse of (1) an empty list,
(2) a list with one element, (3) a list with two elements,
and (4) a list with at least 10 elements.
Your main method should invoke the List's toString method to
print the List before and after reversal.
Other requirements:
Follow the style standards to be found on your instructor's
web page for CPSC 210.
Submit your program using the handin command. There is a link to
the handin description on your lab page (www.cs.clemson.edu/~lab210).
Grading rubric:
Reasonable attempt to solve problem as assigned. 5 pts.
Required documentation and style standards: 10 pts.
The program compiles without error 10 pts.
Program must compile for further points to be awarded.
(Max points for programs that don't compile: 25)
Method previous works with empty list. 5 pts.
Method previous works when current references first SinglyLinkedListElement
in List 5 pts.
Method previous works with all longer lists. 20 pts.
Method reverse works with zero or one elements. 5 pts.
Method reverse works with two elements. 5 pts.
Method reverse works with all longer lists. 10 pts.
Method reverse uses does not create any new SinglyLinkedListElements
(i.e., works by swapping references to SinglyLinkedListElements).
20 pts.
Elegance of code 5 pts.