/**
* Client to test the Length class on the empty list, a one-element list, and
* a two-element list
* @author DXN
*/
public class TestLength {
/**
* Calls the Length class to calculate the length of a list and prints the
* result.
* @param list an AList whose length is to be computed and printed.
*/
private void testLength(AList list) {
System.out.println(list + " has length " + Length.CalcLen(list));
}
/**
* Creates the empty list, a one-element list, a two-element list and
* prints out their lengths.
*/
public void run() {
AList e0 = EmptyList.Singleton;
testLength(e0);
AList e1 = new NEList("one", e0);
testLength(e1);
AList e2 = new NEList("two", e1);
testLength(e2);
}
/**
* Main entry point to test program.
* @param nu not used.
*/
public static void main(String[] nu) {
new TestLength().run();
}
}