Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How Do I? (http://www.alice.org/community/forumdisplay.php?f=28)
-   -   Explain parameter and arguments (http://www.alice.org/community/showthread.php?t=11710)

justmyway2 04-11-2017 03:57 PM

Explain parameter and arguments
 
Hello all,

Would someone be able to explain parameter and arguments to someone that had no coding background? I have been struggling to pick up on this even though other class posts help a bit. If it could be put in terms like the "For Dummies" books that would be beneficial.

Thanks
JB

chickentree 04-12-2017 11:31 PM

Parameters
 
1 Attachment(s)
[QUOTE=justmyway2;57538]Hello all,

Would someone be able to explain parameter and arguments to someone that had no coding background? I have been struggling to pick up on this even though other class posts help a bit. If it could be put in terms like the "For Dummies" books that would be beneficial.

Thanks
JB[/QUOTE]

When you write a method parameters can be used to pass information to the method. This information can be used and changed within the method without affecting the original values. This allows your method more flexibility.
In the example program I have created a World.lightOn method that takes 4 parameters[INDENT]
Type Name Use
Boolean fromDark If true turn brightness to 0 before starting.
Number time Time to take to change the brightness.
Number maxBrightness How bright to make the light.
Color lightColor What color the light gives off.
[/INDENT]
So using this new method you can change the light intensity and color by changing the parameters passed in.

Hope this helps
Mark


All times are GMT -5. The time now is 08:32 AM.

Copyright ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.