// These end up inside the main class static class LBox extends LearnerImpl { static boolean debug; Learner middleLearner; char topChar, bottomChar; *(Learner middleLearner) { this.middleLearner = middleLearner; } // An optimization, but a bit of a dangerous one: /*public void forwardSecretExample(Object _in, Object _out) { String in = (String) _in, out = (String) _out; L l = toLines(out); String middle = l.get(2); middleLearner.processInOut(in, middle); }*/ public void tryAgain() { middleLearner.tryAgain(); } public void processInOut(Object _in, Object _out) { String in = (String) _in, out = (String) _out; L l = toLines(out); String middle = l.get(2); middleLearner.processInOut(in, middle); topChar = l.get(1).charAt(0); bottomChar = l.get(3).charAt(0); } public Object processIn(Object in) { String middle = (String) middleLearner.processIn(in); return "\n" + main.repeat(topChar, middle.length()) + "\n" + middle + "\n" + main.repeat(bottomChar, middle.length()) + "\n"; } public void toJava(Code code) { todo(); } } static class LBox2 extends LearnerImpl { static boolean debug; Learner middleLearner; char topChar, bottomChar, tlChar, trChar, blChar, brChar; *(Learner middleLearner) { this.middleLearner = middleLearner; } public void tryAgain() { middleLearner.tryAgain(); } public void processInOut(Object _in, Object _out) { String in = (String) _in, out = (String) _out; L l = toLines(out); String middle = l.get(2); if (debug) System.out.println("Forwarding to middle learner: " + quote(in) + " => " + quote(middle)); middleLearner.processInOut(in, middle); String top = l.get(1), bottom = l.get(3); tlChar = top.charAt(0); topChar = top.charAt(1); trChar = top.charAt(top.length()-1); blChar = bottom.charAt(0); bottomChar = bottom.charAt(1); brChar = bottom.charAt(bottom.length()-1); } public Object processIn(Object in) { String middle = (String) middleLearner.processIn(in); return "\n" + tlChar + main.repeat(topChar, middle.length()-2) + trChar + "\n" + middle + "\n" + blChar + main.repeat(bottomChar, middle.length()-2) + brChar + "\n"; } public void toJava(Code code) { todo(); } }