// This Java file was automatically generated by ToonTalk for Feb 19b import ap.toontalk.*; // Robot10_2139676692: Factorial Demo class Robot10_2139676692 extends TTRobot { Robot10_2139676692(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; // move to the stack of numbers temp1 = new TTNumber(1); // pick up a number hand = temp1; // drop it on the second hole inside his box given.holeGets(1, hand); // 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); temp2 = hand; // push 'x' to change the last thing he made or found temp2.keyboard('x', true); temp2.stoppedTyping(); // drop what he just copied on the first hole inside his box given.holeGets(0, hand); // release the magic wand return this; // This robot has finished and will see if the box still matches his thoughts and try again. } } // Robot9_589876: Finish Factorial class Robot9_589876 extends TTRobot { Robot9_589876(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; // pick up what's in the first hole inside his box hand = given.pickUp(0); // give it to the bird in the fifth hole inside his box given.hole(4).gets(hand); // move to the stack of bombs temp1 = TT.BOMB; // pick up a bomb hand = temp1; // use it throw new TTBombExplosion(); // bomb set off } } // Robot1901_3406532678: Start Factorial class Robot1901_3406532678 extends TTRobot { Robot1901_3406532678(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; // move to the stack of boxes temp1 = new TTBox(1); // pick up a box hand = temp1; // push '3' to change what he is holding hand.keyboard('3', false); hand.stoppedTyping(); // 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); // move to the stack of numbers temp3 = new TTNumber(1); // pick up a number hand = temp3; // drop it on the second hole inside the new box temp1.holeGets(1, hand); // move to the stack of scales temp4 = new TTScale('?'); // pick up a scale hand = temp4; // drop it on the third hole inside the new box temp1.holeGets(2, hand); // add 'S' to the label of the first hole inside the new box // add 'o' to the label of the first hole inside the new box // add the space bar to the label of the first hole inside the new box // add 'F' to the label of the first hole inside the new box // add 'a' to the label of the first hole inside the new box // add 'r' to the label of the first hole inside the new box // pick up the new box hand = temp1; // drop it just left of his box given.sideGets(hand, false); return this; // This robot has finished and will give the box to the first robot to try again. } } public class FactorialDemo extends TTApplet { public static void main(String args[]) { new TTFrame().begin(new FactorialDemo()); } public void initialize() { intializeToonTalkImages(); intializeNests(); TTNotebook notebook = TT.NOTEBOOK; TTRobot next_robot; TTBox box2 = new TTBox(2); box2.setHole(0, nest0); box2.setHole(1, new TTBird()); answer[answer_count] = new TTNest("The factorial\rof your input\rnumber is "); // Make a nest for a bird without one. box2.hole(1).setNest(answer[answer_count++]); // We just made a box with 2 holes. The first hole contains an empty nest. // The second hole contains a bird. TTRobot robot1 = new Robot10_2139676692(notebook); TTBox box3 = new TTBox(5); TTBox wants8 = box3; // This robot will only accept a box with 5 holes. The hole labeled with "So // far" contains any number. The second hole contains any number. The third // hole contains a scale tipped to the right. The hole labeled with "N" // contains any number. The hole labeled with "Factorial" contains a bird. wants8.setHole(0, TT.BLANK_NUMBER); wants8.setHole(1, TT.BLANK_NUMBER); wants8.setHole(2, new TTScale('<')); wants8.setHole(3, TT.BLANK_NUMBER); wants8.setHole(4, new TTBird()); robot1.setWants(wants8); TTTeam team1 = new TTTeam(box2, robot1); TTRobot robot5 = new Robot9_589876(notebook); TTBox box6 = new TTBox(5); TTBox wants9 = box6; // This robot will only accept a box with 5 holes. The hole labeled with "So // far" contains any number. The second hole contains any number. The third // hole contains a balanced scale. The hole labeled with "N" contains any // number. The hole labeled with "Factorial" contains a bird. wants9.setHole(0, TT.BLANK_NUMBER); wants9.setHole(1, TT.BLANK_NUMBER); wants9.setHole(2, new TTScale('=')); wants9.setHole(3, TT.BLANK_NUMBER); wants9.setHole(4, new TTBird()); robot5.setWants(wants9); robot1.setNextRobot(robot5); TTRobot robot8 = new Robot1901_3406532678(notebook); TTBox box9 = new TTBox(2); TTBox wants10 = box9; // This robot will only accept a box with 2 holes. The hole labeled with "N" // contains any number. The hole labeled with "Factorial" contains a bird. wants10.setHole(0, TT.BLANK_NUMBER); wants10.setHole(1, new TTBird()); robot8.setWants(wants10); robot5.setNextRobot(robot8); setStartingTeam(team1); displayThis(team1.getBox()); } protected static TTNest nest0; private void intializeNests() { nest0 = new TTNest("Please\renter\ra positive\rnumber here"); } private void intializeToonTalkImages() { } }