package username.tests; import java.io.PrintWriter; import username.functions.ComposeUIF; import username.functions.ConstantUIF; import username.functions.IdentityUIF; import username.functions.LogUIF; import username.functions.ProductUIF; import username.functions.QuotientUIF; import username.functions.UnaryIntegerFunction; import username.analysis.Graph; /** * Whee! Let's graph some functions. * * @author Samuel A. Rebelsky * @version 1.0 of April 2006. */ public class GraphFuns { public static void test(PrintWriter pen, char ch, Graph g, UnaryIntegerFunction f) { g.setPlotChar(ch); pen.println(ch + " " + f); for (int n = 1; n < 60; n++) { g.plot(n, f.apply(n)); } } // test(Graph, UnaryIntegerFunction) public static void main(String[] args) throws Exception { PrintWriter pen = new PrintWriter(System.out, true); Graph g = new Graph(70,25); test(pen, '*', g, new LogUIF(2)); test(pen, '+', g, new QuotientUIF(new ProductUIF(new LogUIF(2), new IdentityUIF()), new ConstantUIF(25))); test(pen, '@', g, new QuotientUIF(new ProductUIF(new IdentityUIF(), new IdentityUIF()), new ConstantUIF(100))); test(pen, '.', g, new ComposeUIF(new ProductUIF(new IdentityUIF(), new IdentityUIF()), new LogUIF(2))); pen.println(g); } // main(String[]) } // class GraphFuns