Alice Community Hmmm... a little help? How do I create a Function do do this:

 Hmmm... a little help? How do I create a Function do do this:
 ragtop12 Guest   Status: Posts: n/a Hmmm... a little help? How do I create a Function do do this: - 03-16-2007, 07:36 AM Hey all... I am a CPSC tutor for the local College, and this is the 1st semester we are using Alice for our one class. Anyways, I have to learn as the students learn and am having some troubles with functions. What the students have to do is create a world with a cat and 3 spanish worlds. When a user clicks on the spanish word for cat (gato), the cat shakes his head up and down and if the user clicks on a word other than gato, the cat shakes his head no. The student is to create a function called isGato that does this. A parameter in isGato has to be called objectClicked. I am uncertain if I can use If statements in the Function, or how I would go about doing this. I know the easy way to do this is by creating new events for each word, but the problem specifically wants you to create a function. Any help would be appreciated! Thanks! Obed
 Boolean Function
 gdev Guest   Status: Posts: n/a Boolean Function - 03-16-2007, 07:41 AM Create a boolean function. Have the function use an if statement to check if the word is correct. If it is have it return true if it is the wrong word have the function return false. Just drag the if statement into the line above the return line in the function. Then drag the return statement into the then and else parts. Or create a local variable that is returned for cleaner code. See the message a few down entitled Boolean Functions for some examples/more information.
ragtop12
Guest

Status:
Posts: n/a
03-16-2007, 12:42 PM

Quote:
 Originally Posted by gdev Create a boolean function. Have the function use an if statement to check if the word is correct. If it is have it return true if it is the wrong word have the function return false. Just drag the if statement into the line above the return line in the function. Then drag the return statement into the then and else parts. Or create a local variable that is returned for cleaner code. See the message a few down entitled Boolean Functions for some examples/more information.
Thanks for the reply. For some reason, it wont let me drag the return statement into the else part of the conditional. Oh well, this is frustrating, lol

 hmmm
 gdev Guest   Status: Posts: n/a hmmm - 03-17-2007, 08:34 AM I don't know why it won't let you drag return into the else portion. Make sure you are dragging return from the bottom list of options, it won't let you move the return that automatically is placed in a boolean function. Also make sure you have created a boolean function. Also another option is to create a local variable that is boolean. Have the then part set it to true and the else part set it to false and then just use the return statement that is automatically there just return the variable. Hope that helps.

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge