CIT020 Index > Alice Assignment: Selection and Loops

Alice Assignment: Selection and Loops

Read everything before doing anything.

Part 1

Create a world with the island and the palm tree. Put a fish at the left of the island (as you view it). Place a penguin in the world (anywhere you like). If the penguin is closer to the fish than the tree, have the penguin say I think I'll eat some fish. Otherwise, have the penguin say I think I'll eat a coconut. Save this world in a file whose name has the form lastname_firstname_decision.a2w Make sure you test this world with the penguin in a variety of locations.

Your code must work no matter where the fish, penguin, and island are relative to each other. You cannot just say “if the distance is greater than 5 meters...”

The penguin just makes a statement; it does not move, or turn around, or do any other sort of animated goodness. The fish and tree do not move or say anything either. (If you do want to add something extra for your own amusement, tell me about it first before you turn in the assignment.)

Extra Credit

If the distance from the penguin to the fish and the distance from the penguin to the tree are within 0.05 meters of each other, have the penguin say I can't decide what to eat.

Part 2 - Snowman to Stool

Do exercise seven on page 67. Save the world in a file whose name has the form lastname_firstname_loop.a2w

Part 3 - Snowman to Stool (version 2)

Do exercise seven on page 67, but instead of using Loop, use While to move the snowman towards the stool while the distance from the stool to the snowman is greater than 0.25 meters. As in the previous part, your program must work no matter where the snowman and stool are located. You will save the world in a file whose name has the form lastname_firstname_while.a2w

When You Finish

Attach the .a2w files to an email and send it to the instructor. You must put the words CIT020 Assignment 2 in the subject line of your email, or it will not be graded.