CompSci 4 Test 1 Fall 2005 Total points is: 81. 1) B 2) B 3) A 4) D 5) A, B, D 6) A) height B) 3 C) boolean D) 1) B M C 2) M C 3) F C E) False 7) see picture 8) C D 9) A) 8 B) 5 10) penguin turn to face soccerBall penguin move forward (penguin distance to soccerBall - (soccerBall's width/2) penguin move up (soccerBall's width) penguin move forward (soccerBall's width/2) penguin turn to face lighthouse soccerBall turn to face lighthouse // need so they can move in same direction penguin vehicle set to soccerBall soccerBall move forward 10 meters 11. A) if ball1 color == someColor return ball1 else if ball2 color == someColot return ball2 else return ball3 B) penguin move to WhichObjectIsThisColor someColor=red ball1=tennisBall ball2 = tennisBall2 ball3=tennisBall3 lemur move to WhichObjectIsThisColor someColor=purple ball1=tennisBall ball2 = tennisBall2 ball3=tennisBall3 flamingo move to WhichObjectIsThisColor someColor=yellow ball1=tennisBall ball2 = tennisBall2 ball3=tennisBall3 12 A) if (ball1's width > ball2's width) and (ball1's width > ball3's width) return ball1 else if (ball2's width > ball3's width) return ball2 else return ball3 ALTERNATIVE SOLN if (ball1's width > ball2's width) if (ball1's width > ball3's width) return ball1 else // ball3 is wider than ball 1, ball 1 wider than ball2 return ball3 else if ball2's width > ball3's width return ball2 else return ball3 B) if person1 distance to LargestBall ball1=ball1 ball2=ball2 ball3=ball3 < person2 distance to LargestBall ball1=ball1 ball2=ball2 ball3=ball3 return true else return false ALTERNATIVE SOLUTION return person1 distance to LargestBall ball1=ball1 ball2=ball2 ball3=ball3 < person2 distance to LargestBall ball1=ball1 ball2=ball2 ball3=ball3 C) LargestBall (ball1=toyBall ball2=toyBall2 ball3=toyBall3) move up 1 meter LargestBall (ball1=toyBall ball2=toyBall2 ball3=toyBall3) move down 1 meter if IsLargestBallClosest person1=coach person2=df ball1=toyBall ball2=toyBall2 ball3=toyBall3 DoInOrder coach turn right 1 revolution dj say "not closer to me else do nothing if IsLargestBallClosest person1=dj person2=coach ball1=toyBall ball2=toyBall2 ball3=toyBall3 DoInOrder dj turn right 1 revolution coach say "not closer to me else do nothing