CompSci 4 Test 2 Soln Spring 2009 1 A) When the world starts do While Shark distance to goldfish > 1 is true When not goldfish.isShowing becomes true 1 B) world.my first method shark turn to face goldfish shark move amount=0.25m toward target=goldfish shark.eat food=goldfish goldfish.reincarnate 1 C) When the world starts, the gold fish says hello and at the same time the while event is true so the shark turns to face the goldfish and starts moving it towards the goldfish until it is close to the goldfish. Then the shark eats the goldfish and the goldfish disappears and reappears on the other side of the seaweed. Then the while event kicks in and the shark repeatedly goes to the goldfish and eats it and the goldfish then reappears on the other side of the seaweed. 2. chicken, penguin stegosaurus, turtle, queenBee, lion 3. A) object B) parameter C) The function returns the first animal in the array that is more than twice the height of someObject. If there is no such object, then it returns someObject. 4. A) 15 B) 20 C) 40 D) She could have used a tool like Powerpoint or Paint to create the word Duke and import it in as a billboard, resizing it to that size. Or she could have used 3-D text to create the word Duke. In either case, she would have needed to glue it to the shirt with the vehicle property. 5. A. 4 B. If the number is greater than 8, then there is no recursion. Notice the else always generates a larger number, so that eventually the number will be greater than 8 and the recursion will stop. C. 13 10 23 6. A) score.increment adds to the score, but does not display the new value of the score. To do this you need to add the line: score set text to score.currentValue as a string B) score.increment 123 amount 123 ranNum ranNum set value to random number min=1 max=amount+1 integerOnly=true score.currentValue set value to score.currentValue + ranNum score set text to score.currentValue as a string randomNumber set text to ranNum as a string Add in a 3D text called randomNumber and set it's text to 0 initially. 7. Do Together horse turn to face princess // Assume knight glued to the horse. dragon turn to face princess while knight distance to princess>1 and dragon distance to princess>1 horse.gallop dragon.fly if knight distance to princess <=1 princess say "Thanks for saving me!" else princess say "The Dragon has got me!" 8. A. In code below: IFP is item_from_penguins obj world.GetColoredPenguin 123 distance color selectedColor For all world.penguins, one obj item_from_penguins at a time if IFP.color==selectedColor and lighthouse distance to IFP