/** an DeptDirectory is either: * (i) the empty directory new Empty(), or * (ii) the non-empty directory new Cons(Entry,DeptDirectory) */ abstract class DeptDirectory {} class Empty extends DeptDirectory { public String toString() { return("");} } class Cons extends DeptDirectory { Entry first; DeptDirectory rest; /* constructor */ Cons(Entry f, DeptDirectory r) { this.first = f; this.rest = r; } /* accessors */ Entry getFirst() { return this.first; } DeptDirectory getRest() { return this.rest; } public String toString() { return(first.toString() + " " + rest.toString());} } class TestClass { public void test() { DeptDirectory d = new Cons(new Entry("Corky","DH3104","x 6042"), new Cons(new Entry("Matthias","DH3106","x 5732"), new Empty())); System.out.println(d); } }