5. Acting differently (parameters)

In the dancing example in Module 4, every dancer does the same thing. Is that how you dance? Do you do exactly the same as everyone else? I doubt it! At a party, there'll be lots of dancers, but they'll all be doing it just a little (or a lot!) differently. For example, in Module 4, I'm sure the zombie would do a crazier dance than the teacher.

Notice how we're thinking about activities here. Every character is going to do a dance in the middle (we've learned how to do that already), but each of them might do a part of it slightly differently - for example, when they get to the jump and spin part, some may spin more times than others. I bet the zombie can do a crazy number of spins. See? All the characters will do the basic moves of the dance - this activity is shared by all of them - but there's a little variation in the number of spins each of them puts in. A common part with variation.

Alice let's us add in this variation, and we'll be exploring this now.

so let's have a look at it in action before going any further...

Things you will learn in this module:

    1. Up to now, our methods have only taken one parameter at most, but we will see how methods can take any number of parameters.
    2. The values we've passed into methods have so far always been characters in our world. We will see that we can pass in any kind of value - particularly numerical values - and how this can be useful in specifying the variation we are going to explore.

Vocabulary for this module:

Parameter Type: This is specified at the time the parameter is created, and indicates what kind of value to expect when the method is called - for example, will it be a character in the world or a numerical value?

Default Value: If a parameter is added to an existing method, then Alice automatically updates every call to the method to include a parameter value. Alice uses a default or standard value for this - for example, for the numeric type, Alice uses the number one.

Get Started! >>