Translating an algebraic specification into Java. Recipe for implementing an immutable ADT that is specified by an algebraic specification. Let T be the name of the ADT. Assumptions: Except for the basic creators, each operation of the ADT takes at least one argument of type T. Except for the basic creators, each operation is specified by one or more equations. If an operation is specified by more than one equation, then the left hand sides of the equations differ according to which basic creator was used to create an argument of type T. The equations have certain other technical properties that allow them to be used as rewriting rules. We are to implement the ADT in Java. The operations of the ADT are to be implemented as static methods of a class named T. Recipe: Determine which operations of the ADT are basic creators, and which are other operations. Define an abstract class named T. For each creator c of the ADT, define a concrete subclass of T whose instance variables correspond to the arguments that are passed to c. For each such subclass, define a Java constructor that takes the same arguments as c and stores them into the instance variables. [So far we have defined the representation of T. Now we have to define the operations.] For each operation f of the ADT that is not a creator, define an abstract method f that takes one less argument than f. The missing argument should be of type T. If f has more than one argument of type T, then the missing argument should be the argument that discriminates between the various equations for f. For each operation of the ADT, define a static method within the abstract class. If the operation is a basic creator c, then this static method should create and return a new instance of the subclass that corresponds to c. If the operation is not a basic creator, then this static method should delegate to the corresponding dynamic method, passing it all but one of its arguments. (The missing argument will be available to the dynamic method via the special variable named "this".) Suppose, for example, that the static method T.f is called with arguments x1, x2, x3, and x4, where x1 is the only argument of type T. Then the body of T.f should be return x1.f (x2, x3, x4); For each operation f of the ADT that is not a basic creator, and for each concrete subclass C of T, define f as a dynamic method within C that takes the arguments that were declared for the abstract method f and returns the value specified by the algebraic specification for the case in which Java's special variable this will be an instance of C. If the algebraic specification does not specify this case, then the code for f should throw a RuntimeException such as an IllegalArgumentException.