Alice Community  

Go Back   Alice Community > Educators > Teaching with Alice

Reply
 
Thread Tools Display Modes
Parameters
Old
simsman2011
Senior Member
 
simsman2011's Avatar
 
Status: Offline
Posts: 132
Join Date: Jul 2011
Location: somewhere on Earth
Default Parameters - 08-16-2011, 02:07 PM

I want to know what can the parameters be used for?.......


==========ــــــــــــــــــــــــــــــــــــــ==============
==========SiMsMaN.....2O11=============
==========ــــــــــــــــــــــــــــــــــــــ==============
   
Reply With Quote
Old
David B
Senior Member
 
David B's Avatar
 
Status: Offline
Posts: 1,145
Join Date: Dec 2010
Location: N/A
Default 08-16-2011, 02:18 PM

Quote:
Originally Posted by simsman2011 View Post
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!
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 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.
   
Reply With Quote
Old
simsman2011
Senior Member
 
simsman2011's Avatar
 
Status: Offline
Posts: 132
Join Date: Jul 2011
Location: somewhere on Earth
Default 08-17-2011, 07:29 AM

Can you give another examples......
(there is different types : number, string, object....etc.)


==========ــــــــــــــــــــــــــــــــــــــ==============
==========SiMsMaN.....2O11=============
==========ــــــــــــــــــــــــــــــــــــــ==============
   
Reply With Quote
Old
legolizard
Senior Member
 
legolizard's Avatar
 
Status: Offline
Posts: 242
Join Date: Jan 2011
Location: Aboard the Hyperion escaping the zerg.
Default 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:

example2.a2w


"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."-Albert Einstein
   
Reply With Quote
Old
simsman2011
Senior Member
 
simsman2011's Avatar
 
Status: Offline
Posts: 132
Join Date: Jul 2011
Location: somewhere on Earth
Default 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......


==========ــــــــــــــــــــــــــــــــــــــ==============
==========SiMsMaN.....2O11=============
==========ــــــــــــــــــــــــــــــــــــــ==============

Last edited by simsman2011; 08-17-2011 at 03:56 PM.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



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