Use the following files:
LispList.java
public interface LispList
{
LispList NIL = new EmptyList();
boolean isEmpty();
LispList cons(Object obj);
Object head();
LispList tail();
boolean contains(Object obj);
}
LispListTester.java
public class LispListTester
{
public static void main(String[] args)
{
LispList list1 = new EmptyList();
LispList list2 = new NonEmptyList(2, new NonEmptyList(4,
new EmptyList()));
LispList list3 = LispList.NIL.cons("E").cons("D").cons("C").cons("B").cons("A");
System.out.println(list1.contains("E"));
System.out.println("Expected: false");
System.out.println(list2.contains(3));
System.out.println("Expected: false");
System.out.println(list2.contains(4));
System.out.println("Expected: true");
System.out.println(list2.contains("A"));
System.out.println("Expected: false");
System.out.println(list3.contains("A"));
System.out.println("Expected: true");
System.out.println(list3.contains("D"));
System.out.println("Expected: true");
System.out.println(list3.contains("C"));
System.out.println("Expected: true");
System.out.println(list3.contains("K"));
System.out.println("Expected: false");
System.out.println(list3.contains("Z"));
System.out.println("Expected: false");
System.out.println(list3.contains(9));
System.out.println("Expected: false");
}
}