Alice Programming
Learn Alice in FREE step-by-step lessons.
Module 14: Class Procedures in Alice3: Reusable Code
In this module, you will create procedures. Procedures let you write code for an object to perform an action.
For instance, you can write a procedure for a biped to wave. Then, whenever you want a character to wave, you just call the procedure.
The code can then be used many times and for many objects.
This will allow you to decompose a program into functional subprograms and create and test larger programs.
We will also use parameters so that we can tell the procedure how fast to wave, or how many times to wave. We can also use parameters to tell who the bunny faces when they wave.
This a very powerful tool and will let you greatly improve the efficiency of your code.
Goal:
- Learn to create class procedures
- Create procedures for an object to perform actions such as walk or jump
- Understand the advantages of creating procedures
- Use the procedure many times and for many objects
- Decompose a program into functional subprograms
- Use parameters to give the procedure information
- Use parameters so that the same procedure can vary in speed, repetions, or distance
- Use parameters to pass an object, such as a marker, or another object
In order to do this you will:
Objectives:
- Write code to animate a character, then convert that code to a procedure so that it can be used many times and for other characters.
- Utilize parameters for flexibility.
- Decompose a program into subprograms: myFirstMethod will be mostly calls to procedures and functions from now on.