Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
abstract class IntList {
    abstract returnType methodName(parameter_list); // returnType may be void
}
 
class EmptyIntList extends IntList {
    returnType methodName(parameter_list) {
        // base case code
    }
}
 
class ConsIntList extends IntList {
    int first;
    IntList rest;
    returnType methodName(parameter_list) {
        // ... first ...
        // ... rest.methodName(parameter_list) ...
    }
 
}

Problems

Apply the interpreter design pattern to IntList and its subclasses to write the following methods. Also write a JUnit test class to test all methods in EmptyIntList and a different JUnit test class to test all methods in ConsIntList . We strongly recommend that you write Template Instantiations as an intermediate step in developing your code BUT DO NOT submit these Template Instantiations (or corresponding Templates) as part of your code documentation. Confine your documentation to writing contracts (purpose statements in HTDP terminology) using javadoc notation. The javadoc documentation style will be discussed in the upcoming lab.

...