import java.awt.*; /** * Prints (by appending) a list of Integers onto a TextArea AWT object. * It does not clear the text area before writing to it. * Returns null always. */ public class TextAreaPrint implements IFunAlgo { private static TextAreaPrint _singleton = new TextAreaPrint (); public static IFunAlgo Singleton() { return _singleton; } private TextAreaPrint() { } public Object forEmpty(EmptyFW host, Object param) { return null; // Nothing to print here. } public Object forCons(ConsFW host, Object param) { TextArea device = (TextArea) param; // saves recasting all the time // appends the integer value of the data as a new line onto the TextArea device.append(host.car().toString() +'\n'); return host.cdr().execute(this,device); // recur on the rest of the list } }