// XEmacs: This file contains Java source code, so use -*- JDE -*- mode.

// ComposeTester: demonstrate the use of procedural composition in Java

// John David Stone
// Department of Mathematics and Computer Science
// Grinnell College
// stone@cs.grinnell.edu

// created August 30, 2000
// last revised August 30, 2000

import Compose;

public class ComposeTester {
    public static void main(String[] args) {

        // The composer composes unary procedures at run time.

        Compose composer = new Compose();

        // Build and apply a successor-of-square procedure.

        UnaryProcedure successorOfSquare = (UnaryProcedure) composer.apply(new Successor(), new Square());
        System.out.println("The successor of the square of 5 is " + ((Long) ((UnaryProcedure) successorOfSquare).apply((Object) (new Long(5)))).longValue() + ".");

        // Build and apply a square-of-successor procedure.

        UnaryProcedure squareOfSuccessor = (UnaryProcedure) composer.apply(new Square(), new Successor());
        System.out.println("The square of the successor of 5 is " + ((Long) ((UnaryProcedure) squareOfSuccessor).apply((Object) (new Long(5)))).longValue() + ".");
    }
}
