// This Java file was automatically generated by ToonTalk for Feb 21 import ap.toontalk.*; // Robot1844_1599229988: Fibonacci Worker class Robot1844_1599229988 extends TTRobot { Robot1844_1599229988(TTNotebook n) { notebook = n; } public TTObject gets(TTObject given) throws TTException { if (!wants.matches(given)) return null; // If given a box that matches the box in his thought bubble (called "wants"), // this robot will do the following: TTObject hand; TTObject temp1; TTObject temp2; TTObject temp3; TTObject temp4; // grab a magic wand TTCopier copier = new TTCopier(); hand = copier; // use the magic wand on the second hole inside his box hand = copier.applyTo(given.hole(1), this); temp1 = hand; // drop it temp1 = hand; // use the magic wand on the third hole inside his box hand = copier.applyTo(given.hole(2), this); // drop what he just copied on the first thing he made or found temp1.gets(hand); // release the magic wand // pick up what's in the second hole inside his box hand = given.pickUp(1); // drop it temp3 = hand; // pick up what's in the third hole inside his box hand = given.pickUp(2); // drop it on the second hole inside his box given.holeGets(1, hand); // pick up the first thing he made or found hand = temp1; // drop it on the third hole inside his box given.holeGets(2, hand); // grab a magic wand hand = copier; // use the magic wand on the third hole inside his box hand = copier.applyTo(given.hole(2), this); // give what he just copied to the bird in the first hole inside his box given.hole(0).gets(hand); // release the magic wand // grab a copy of Dusty return this; // This robot has finished and will see if the box still matches his thoughts and try again. } } // Robot1842_4178227307: Fibonacci Start class Robot1842_4178227307 extends TTRobot { Robot1842_4178227307(TTNotebook n) { notebook = n; } public TTObject gets(TTObject given) throws TTException { if (!wants.matches(given)) return null; // If given a box that matches the box in his thought bubble (called "wants"), // this robot will do the following: TTObject hand; TTObject temp1; TTObject temp2; TTObject temp3; // move to the stack of boxes temp1 = new TTBox(1); // pick up a box hand = temp1; // drop it temp1 = hand; // move to the stack of numbers temp2 = new TTNumber(1); // pick up a number hand = temp2; // drop it on the first hole inside the new box temp1.holeGets(0, hand); // grab a magic wand TTCopier copier = new TTCopier(); hand = copier; // use the magic wand on the new box hand = copier.applyTo(temp1, this); temp3 = hand; // drop what he just copied just right of the new box temp1.sideGets(hand, true); // release the magic wand // pick up the new box hand = temp1; // drop it just right of his box given.sideGets(hand, true); return this; // This robot has finished and will give the box to the first robot to try again. } } public class FibonacciNumbers extends TTApplet { public static void main(String args[]) { new TTFrame().begin(new FibonacciNumbers()); } public void initialize() { intializeToonTalkImages(); intializeNests(); TTNotebook notebook = TT.NOTEBOOK; TTRobot next_robot; TTBox box2 = new TTBox(1); box2.setHole(0, new TTBird()); answer[answer_count] = new TTNest(); // Make a nest for a bird without one. box2.hole(0).setNest(answer[answer_count++]); // We just made a box with one hole which contains a bird. TTRobot robot1 = new Robot1844_1599229988(notebook); TTBox box3 = new TTBox(3); TTBox wants1 = box3; // This robot will only accept a box with 3 holes. The first hole contains a // bird. The second hole contains any number. The third hole contains any // number. wants1.setHole(0, new TTBird()); wants1.setHole(1, TT.BLANK_NUMBER); wants1.setHole(2, TT.BLANK_NUMBER); robot1.setWants(wants1); TTTeam team1 = new TTTeam(box2, robot1); TTRobot robot4 = new Robot1842_4178227307(notebook); TTBox box5 = new TTBox(1); TTBox wants2 = box5; // This robot will only accept a box with one hole which contains a bird. wants2.setHole(0, new TTBird()); robot4.setWants(wants2); robot1.setNextRobot(robot4); setStartingTeam(team1); displayThis(team1.getBox()); } private void intializeNests() { } private void intializeToonTalkImages() { } }