View Full Version : Parameters

08-16-2011, 02:07 PM
I want to know what can the parameters be used for?.......

David B
08-16-2011, 02:18 PM
I want to know what can the parameters be used for?.......

Parameters are used with methods. It is impossible to describe the purpose of Parameters without the use of an example, so here goes...

Say that you have created a model of a person (whether you truly modeled it yourself, or used the Person Builder, it doesn't matter), and you want to make a method for the person so that it looks like he is walking. You want to make the method in a manner that allows you to choose how many steps he makes when the method is used in another method. To do this, you have to create a parameter. After creating the parameter, you begin to write the code that makes the person look like he is walking, but when you get to the point when you have to state how many meters you want the person to move forward, and how many steps you want the person to make, you don't put in a number for this, but rather put the variable which you created in there. You can then test to see that the method works by dragging the method you created to get the person to walk into the "my first method" method. Upon dragging the method in, however, unlike most custom-made methods, you will be asked to input the value of the parameters. You can have as many or as few parameters as you want (you don't even have to have any if you don't want!).

I hope this helps!

08-16-2011, 03:43 PM
Personally, I use parameters to eliminate redundancy. Passing objects in as parameters will allow you to make several similar objects perform similar functions without writing a method for each individual object or function.

08-17-2011, 07:29 AM
Can you give another examples......
(there is different types : number, string, object....etc.)

08-17-2011, 03:30 PM
Parameters are variables or arguments that are passed to other functions and methods to be used. They are especially useful so that you only have to make one method that takes a parameter instead of making many methods that do the same task. On example I can think of is you could make a method called calculate that can add subtract divide and multiply.This method would take 3 parameters one to determine what mathmatical operation you want to do say a string and the other two would the numbers you want to use in your problem.

Here is that world in action:


08-17-2011, 03:52 PM
Thanks. I think I got it but I can't find any parameters in the world you have attached it......