Procedures in Alice3: Top Down Code and Reusable Code

Write down the answers first. Click the check to check your answer and to hide the answer.

1. What is the best way to break your code into small manageable pieces? answer

Use procedures and functions

2. If you have a movie and want both the camel and the elephant walk, what class would you write the walk procedure for? answer

Quadruped

3. What does this button do ? answer

It lets you add procedures, functions and properties to a class.

4. You have written some code for the bear to walk. When you copy the code to a procedure you will need to change bearCub to ___. answer

this

5. A procedure header is shown below. What are amount, speed and number Of Times called?
answer

parameters

6. A procedure header is shown below.

The calling statment is
How many times does the bear cub shake his head? answer

3

7. The values that you see in the calling statement are called _____ answer

arguments

8. What will the code below do?
answer

The bear says “hello” at random intervals throughout the movie.

9. With the code shown below, when will the bear face the castleGate?
answer

Never! This is an endless loop and the last line is never executed.

10. You have a movie with 5 different fish. You want all of them to swim. What is the best way to do this? answer

Create a swim procedure for the Swimmer class.

Please review the materials for any questions you miss.

NEXT: