CompSci 94 Fall 22 Test 2 Solution Problem 1 Part A 1) Pig says no, then pig says yes 2) Penguin says yes, then penguin says yes Problem 1 Part B 1) pig says "red" 2) penguin says "blue" 3) creature penguin, number anything < 2.0 and color is "blue" For example creature = this.penguin, somenumber = 1.0 and color = "BLUE" Problem 2 Part A 1) 20 times 2) 5 times Part B 1) 3 times 2) I'm this far from you 1.5 Part C 1) 2 times 2) I'm this far from you 0.0 Problem 3 A) The animals turn to the right, all the way around once, one at a time in the order they are in the animals array. bunny first, then hare, then panda, then pig B) The animals in the array (bunny, hare, panda and pig) all move right one unit at the same time. C) All the animals in the animals array (bunny, hare, panda and pig) all say go at the same time, then duke at the same time, and then blue at the same time D) It is not possible to add a Cow to the Biped array because a Cow is a quadruped. Problem 4 declare procedure resizeRandomly with parameter: Decimal Number somenum do in order randomNum = nextRandomWholeNumberInRange1,3 if randomNum == 1 is true then this resize somenum else if randomNum == 2 is true then this resize 1.4 else this resize 0.6 Problem 5 declare procedure colorful with parameter: Paint newColor, Biped animal do in order animal setPaint newColor DecimalNumber originalHeight = animal getHeight while animal getPaint not equal to BLUE is true animal resize Randomly somenum = 2.0 if animal getHeight > originalHeight * 2 is true then animal setPaint BLUE Problem 6 Bunny Procedure declare procedure visit with parameters Biped creature do together this.turnToFace creature creature turnToFace this while bunny distanceTo creature > 2.0 bunny walk if bunny.getHeight < creature.getHeight is true then this.resize 1.2 else creature.resize 1.2 Problem 7 Bunny Procedure declare procedure repeatedVisits with parameters Biped animal1, Biped animal2, WholeNumber loopcount count up to loopcount if this.getDistanceTo animal1 > this.getDistanceTo animal2 is true then this visit animal1 else this visit animal2