Adventures in

Alice Programming

Duke University, Durham, NC

Alice Programming Header Graphic

Lists/Function Exercise

Write an Alice world with the following story.

PART 1:

Setup a scene on any ground you want with the following characters. From the people folder and then the walking people folder: pick iceSkater, toySoldier and leafFlameglimmer. Resize the toySoldier so he is clearly taller than the others. From the animals folder, add the frog. Here is the scene setup. The iceSkater is on the right facing everyone. The others are in a line, first the toySoldier, then the frog and then the leafFlameglimmer, like this:

Be sure to use the quadview and look from the top to see if they are all in a line like this:

PART 2:

Put everyone except the iceSkater into a list. Have the ice skater raise her arm part way and have everyone in the list turn around twice.

PART 3:

Write a function to compute the difference in height between the iceSkater and another object. The number returned should be positive. Note the other object could be taller or shorter than the iceSkater.
Question: Should the function be a world function or an iceSkater function?

Question: Should the function be flexible? How many parameters?

Now have the iceSkater raise her arm all the way up. Everyone in the list should rise the amount that is the difference in height between that object and the iceskater (hint: call your new function).

Notice that the top of everyone who was shorter than the iceSkater is now floating in the air, but the same height as the iceSkater's head (the fairy's height is the top tip of its wings). Anyone who was taller than the iceSkater is also floating but way above the iceSkater's height.

PART 4:

For this part, the iceSkater raises her arm halfway back down and any object in the list who is taller than the iceSkater should move down so that the top of its head is now the same height as the iceSkaters (meaning their feet should go into the ground), like this:

PART 5:

For this part, add two new objects into your world, one taller than the iceSkater (I added Hare and resized him larger) an object taller) and an object that is smaller than the iceSkater (I added husky). Add them to your list and run your program. They are now in the list and all the commands we did with others in the list should be applied to them automatically. Here is the picture at the end now: