I have two arrays, each filled with 1000 objects of my own class.
What I want is a recursive loop that will have the corresponding index values of each array interact in a predefined way.
Array One: 1, 3, 5, 7, 9
Array Two: 2, 4, 6, 8, 10
The way i want them to interact is Array Two minus Array One, then store that in a variable ('1' has a variable for this). Would I do this with a for loop or a while loop, and how would I do it?
How would I achieve something like:
If (array[x] == 0)
where x can be any index, and that code is running all the time?
Find a tutorial on arrays and read it.
Originally Posted by Kaito
In what way do you mean? As is a do while loop?
A do while loop is a good bet.
Also, you'll probably want to use a for loop if you know the size of the array you're iterating on.
Alright, new problem statement, which should make more sense:
"At index 0, have some code run that will randomly subtract either 2 or 0 from a counter. When the value at index 0 reaches 0, I want the same bit of code to run for index 1, then index 2, etc, until the last index value has been reached"
Does this make it easier to understand?
Yes your new statement makes a lot more sense.
You say you want to go through each index value. You can probably figure out what kind of loop you need to go through each one.
Then, for each of those values, you want to keep going until the value at the index is 0. Again, try to think of what loop you need for that.
Inside that 2nd loop you can do your random subtractions. Try to see if you can do this, it should be a fairly big hint as to how to proceed.