Quote:
Originally Posted by Mr Kidnapper
I have no idea why you would want to loop in a while when all you need to do is ask the user how many times they want to loop and store it in a variable, but this is how "while" loops are done.
While ( both ( world.booleanVariable == true ) and ( world.numberVariable <= 2 ) )
increment world.numberVariableby 1
And in Java,
boolean Vars1;
int Vars2=0;
int Vars3=3;
while ( Vars1 == false && Vars2 <= Vars3 ){
Vars2++;
};
Simply put, a while loop can ask if a variable is true or if it has not reached a certain number yet, in this case 2. It is used to make very complicated loops that require you satisfy many conditions first. At the end of a while function, or in any part of the function really, Vars2++ is used to increment the number, currently at 0, by 1. This in particular make the while loop a total of 3 times, assuming Vars1 is true. If Vars1 is not true, it will loop to infinity or until it becomes true.
I really don't see why you can't just use the regular loop for this.
|
Thanks for the help!
I had 2 or 3 conditions before the while loop that needed to be met to process the while loop i was talking about.
Didnt end up needing to increment, just got my variable to + 1 while the user number input was <=0 then added the next method. (this was added to an "else" part of an if statement that was part of the prior conditions that needed to be met.)
Works beautifully now : )