CompSci 4 Test 1 Solutions Fall 2011 1. D 2. User can click on the word vampires or the picture vampires.org 3. Will be displayed as (with "beat Florida this" italized and weekend in bold): Duke beat Florida this past weekend 4. The content in the title tag is displayed on the title bar at the top of the browser window. In this case "Ice Cream" would be on the title bar. 5. B 6. B 7. C 8. With move the head will come off. With turn the part moves but stays attached to the body. 9. A) wolf.spinner is the function. It returns a color B) boolean C) built-in method D) method E) flamingo, 3 F) some, temp G) cow is smaller than or equal in height to the flamingo H) cow.someway is the function. It returns a direction 10. see picture 11. A. 67 B. 31 C. 45 12. penguin turn to face armchair penguin move forward (penguin distance to armchair - 2) Do Together penguin move forward 3 + armchair's depth duration = 2 sec Do In Order penguin move up armchairs height duration = 1 sec penguin move down armchairs height duration = 1 sec armchair say "Who are you?" armchair.cushion set vehicle to penguin penguin move forward 20 meters 13. kangarooRobot.paint obj item color newcolor kangarooRobot turn to face item kangarooRobot move forward kangarooRobot distance to item kangarooRobot turn right 1 rev asSeenBy item item set color to newcolor 14 A) obj world.fishToCatch 123 catchsize, obj fish1, obj fish2, obj fish3 if both fish1.color != blue and fish1's depth > catchsize return fish1 else if both fish2.color != blue and fish2's depth > catchsize return fish2 else Do nothing return fish3 B) world.fishToCatch (catchsize=1, fish1=minnow, fish2=lilfish,fish3=uglyFish) say "I'm catchable, try to catch me" world.fishToCatch (catchsize=1, fish1=minnow, fish2=lilfish,fish3=uglyFish) move forward 20 meters 15) A) T/F world.isSlim obj person if (person's height > person's width * 4 return true else return false ALTERNATE SOLUTION: T/F world.isSlim obj person return person's height > person's width * 4 B) obj world.tallestPersonUsingSlimRules obj person1 obj person2 if world.isSlim(person1) if world.isSlim(person2) if person1 is taller than person2 return person1 else return person2 else // person 2 is NOT slim but person1 is return person1 else // person 1 is not slim if world.isSlim(person2) return person2 else // neither person1 nor person2 are slim if person1 is taller than person2 return person1 else return person2 ALTERNATE SOLUTION: obj world.tallestPersonUsingSlimRules obj person1 obj person2 if world.isSlim(person1) and not world.isSlim(person2) return person1 if not world.isSlim(person1) and world.isSlim(person2) return person1 if person1 is taller than person2 return person1 return person2