...
Code Block |
---|
abstract class IntList {
abstract returnType methodName(parameter_list); // returnType may be Void
}
class EmptyIntList extends IntList {
static EmptyIntList ONLY = new EmptyIntList(); // Singleton
private EmptyIntList() {}
returnType methodName(parameter_list) {
// base case code
}
}
class ConsIntList extends IntList {
int first;
IntList rest;
returnType methodName(parameter_list) {
// ... first ...
// ... rest.methodName(parameter_list)...
}
}
|
...