Comp 212 Spring 2001, Homework 2: Lists using Visitors

Due Monday 12 Feb. 2001 10:00 AM.

This homework exercise serves as a drill on applying the visitor pattern to the list data structure. It is based on the previous homework and lab 03.

Your task is to rewrite the solution to the previous homework to use the visitor pattern. You should have a visitor corresponding to each of the toString, makeClone, nthElement, lastElement, firstElements, reverse, and append methods. You are free to add any private and protected methods to your visitor classes to support your public operations. You are also free to write helper visitors to support your main visitors. You are not allowed to check for the type of an object, e.g., using instanceof or an additional method.

Following the style of lab 03, you should have classes named AList, EmptyList, NEList, and ListFactory, which should all be in a package named list. The visitors should be in a package named list.visitor. To follow standard conventions, visitor names should be capitalized, e.g., ToString and MakeClone. The visitors should all be independent of each other.

Grading: We anticipate returning grade reports for assignment 1 prior to your turning in this assignment. Since the two assignments should have the same behavior, you will not be graded here for your test cases. In fact, you may use the ones you see in your assignment 1 feedback. On the other hand, we will now have higher expectations for your code style and documentation.


The homework is due Monday 12 Feb., 2001 10:00 AM. Your directory

should contain the standard files (well-written Java source code including a client to test it all, README, UML diagram, Javadoc documentation) and be submitted from your comp212 directory with the command
     turnin -c comp212 -p hw-visitor hw-visitor