CompSci 94 Spring 2018 Test 2 Solutions Problem 1 1A. Events: sceneActivated, pointOfViewChanged, keyPressed 1B. Bunny turns to face Panda, says hello and the panda turns around. Then the Dalmation turns to face the tortoise, and moves towards the tortoise one unit. 1C. The user can press the letter M. This cause the tortoise to move right just a little and then the panda to move left a little. This results in the Dalmation turning to face the tortoise and move one unit toward the tortoise. That could be repeated. Problem 2 2A. The animals in the array move up 2 units, one at a time with the pig first, then the panda, then the marchHare, then the tortoise, then the stuffed tiger and last the bunny. Next all six animals move back down to the ground at the same time. 2B. The panda turns all the way around, then the marchHare turns all the way around, and then the tortoise turns all the way around. Problem 3 3A. WholeNumber 3B. variable 3C. Any Quadruped could be put into the array. 3D. 0 or 1 3E. The function randomly makes some of the coyotes invisible, and it returns the number of coyotes that it turned invisible. Problem 4 4A. The seagull moves up and down. 4B. Nothing happens 4C. The peacock turns around 4D. Nothing happens Problem 5 5A. scoreDisplay 5B. It would be good to add a parameter that is a WholeNumber, say called amount. Then the code for the procedure would be: scoreNum = scoreNum + amount scoreDisplay setValue scoreNum 5C. Replace the mouseClicked event with two mouseClicked events: 1) Set the items to click on to the penguins array Code: if gameOn is True: updateScore amount = 1 2) Set the items to click on to the bunnies array Code: if gameOn is True updateScore amount = -1 5D. Modify the mouseClicked event for clicking on the penguins array Code: if gameOn is true updateScore amount = 1 if scoreNum >= 10 setGameOn to false ALTERNATE SOLN: Modify myFirstMethod to add at the end of it, right after you set gameOn to true Code: while gameOn == true: if scoreNum >= 10 setGameOn to false Problem 6 6A. The bunny turns around and the fox says hello 6B. The panda jumps up and down and then the poodle turns backward and then forward. 6C. Nothing happens 6D. After the Panda moves up and down, add in the command: panda setOpacity 0.0 Problem 7 The line in the body of the if: return onePerson Should instead be: tallestSoFar = onePerson Problem 8 8A. WholeNumber count = 0 for each Flyer someOne in penguins if Both someOne getHeight >= minRange AND someOne getHeight <= maxRange is true then count = count + 1 loop return count ALT SOLN WholeNumber count = 0 for each Flyer someOne in penguins if someOne getHeight >= minRange if someOne getHeight <= maxRange is true then count = count + 1 loop return count 8B. if BOTH numSmall > numMedium AND numSmall > numLarge is true then eagle say "There are more small penguins" else if BOTH numMedium > numSmall AND numMedium > numLarge is true then eagle say "There are more medium penguins" else eagle say "There are more large penguins" ALT Soln if BOTH numSmall > numMedium AND numSmall > numLarge is true then eagle say "There are more small penguins" else // Know small is not the most if numMedium > numLarge is true then eagle say "There are more medium penguins" else eagle say "There are more large penguins" ALT Soln TextString size = "hello" if BOTH numSmall > numMedium AND numSmall > numLarge is true then size = "small" else if numMedium > numLarge is true then size = "medium" else size = "large" eagle say "There are more " + size + " penguins"