In Modules 4 and 5, you've now added two parameters to the dance in the middle method.
[Q5.5.1]: Before reading on, write down in what ways you think the two parameters are the same, and how they are different.
1. Different: they have different names and different types
2. Same: they both vary the way the dance in the middle method executes.
(2) might be a surprise. After all, we put them in different modules. In Module 4, we wanted to have a different character perform an action each time we called the method. In this module, we wanted to dictate the number of times an action was performed inside the method. These are different, sure - but consider that they both simply enable variation in the way that the dance in the middle method behaves. We could have written a method girl dance in the middle in which the particular dancer is fixed - it's always the girl - but which took a single parameter to indicate how many times she should spin.
To give a sense of how useful this might be, think about life in general. Can you model other activities around you in this general way - a common part repeated in many places, but each time with some variation?
Here are some examples:
1. Clock striking (ringing) on the hour. Basically the same activity, but the number of times it is repeated is different each time to correspond with what hour it is.
2. Coloring in a shape. Start in the middle and colour up to the edges - but the colour could be different each time, and so could the shape.
3. Display some text. Variation could be in the particular text to display, the font used, and the position to display it.
[Q5.5.2]: Now identify two of your own.
Finally, play around with any of the worlds you've worked on so far, adding parameters so that you can vary the behavior easily. For example, you could take the first world you created with methods - the Beetle world, where you split up the activity into escape, freakOut and apologize, and add one or more parameters to any of those methods, and then experiment with calling them with different parameter values. What aspect of each of the methods will you vary? You could follow the video from the start of this module - varying what SlackerProm does. Or change how far the Beetle or RingoBeetle move... it's up to you!