Alice Community If/else and Arrays

 If/else and Arrays
 Ylu Member   Status: Offline Posts: 35 Join Date: Jul 2015 If/else and Arrays - 07-29-2015, 11:22 PM I am currently working on if/else and was told to use index= 0 loop # times if item i from object is .1 meters away from object2 increment +1 end if increment i end loop So I'm confused. I am trying to get redo a series of instructions but using the array instead of individual listing the objects is causing the if in the if/else equation not to function. In the 2nd section - 2 objects are used 3rd section - 3 objects 4th section -4 objects I have an array with all 4 but I am unable to get the it to differentiate b/w each object in the array (in one statement) without having to make a different statement for each. Problem illustration Old structure if either object1 is within 5 meters of the car OR either object2 is within 5 meters of the car OR either object3 is within 5 of the car New structure with problem if either index item is within 5 meters of the car Help, so tired of working on this
chickentree
Super Moderator

Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
07-30-2015, 10:26 AM

Quote:
 Originally Posted by Ylu I am currently working on if/else and was told to use index= 0 loop # times if item i from object is .1 meters away from object2 increment +1 end if increment i end loop So I'm confused. I am trying to get redo a series of instructions but using the array instead of individual listing the objects is causing the if in the if/else equation not to function. In the 2nd section - 2 objects are used 3rd section - 3 objects 4th section -4 objects I have an array with all 4 but I am unable to get the it to differentiate b/w each object in the array (in one statement) without having to make a different statement for each. Problem illustration Old structure if either object1 is within 5 meters of the car OR either object2 is within 5 meters of the car OR either object3 is within 5 of the car New structure with problem if either index item is within 5 meters of the car Help, so tired of working on this
Please upload a movie showing what you are trying to do as well as you are able. Also more information on the movies requirements would help.

If you have your array setup then make the method work with one object not using the array. Then, when the method is working, click on the array and drag it to everywhere the object you've been using appears in the method and select "ith item from array" setting i to a value between 0 and 3.
Finally replace the index you used (0,1,2 or 3) with your index variable in the method.

Mark

Mark Henwood
mhenwood@ieee.org

 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