7. Reflecting

Things we learned about mathematical expressions and functions:

    • In Alice, mathematical expressions allow us to have more carefully controlled interactions among objects (e.g., using specifics about their size and locations to calculate appropriate movement values).
    • Like methods, functions are a convenient way to abstract complicated parts of programs. While methods encapsulate (or hide away) a complex series of instructions or actions, functions encapsulate (or hide away) a complex mathematical expression. This lets us reuse them easily and also lets other people use them without their needing to understand exactly how the function works.
    • When a function is called it returns the value calculated by the mathematical expression inside it. So far, we have used functions as a parameter to a method -- so when we execute that method, the function is evaluated to calculate a specific value for a parameter. (e.g., Such as when we used the function comfortable distance when we needed to move two characters next to one, but not on top of one another).
    • You can pass parameters to functions in the same way as you can pass parameters to methods.

Sample questions you should be able to answer after this module:

[Q7.7.1]: What does a function return?

[Q7.7.2]: Give an example of two things that you could learn about an object using one of Alice's provided object functions (hint: there are more than two).

[Q7.7.3]: What 2 functions would you use to make sure that when the zombie falls off the pier its head stops just below the water's surface (hint: you don't need to describe HOW you would use them, just say which two functions you would need)?

[Q7.7.4]: Can the comfortable distance function be applied to characters other than the Angel and the Coach?

<< Back Return to: Calculating Realism >>