Okay, I have a feeling there is a fairly simple way to do this, but I can't think of it with what I know.
I have four methods (lets call them methodA, methodB, methodC, methodD).
What I need to do is loop through methodA infinitely until I meet a certain condition. When it meets that condition I need to run methodB. Now methodB will run once and either kick me back into the infinite loop of methodA or run onto methodC. methodC will then run once and either kick back to methodA or go to methodD. Finally methodD either kicks back to methodA again or finally ends the loop. methodA also has a possibility to kick out of the loop, but that part I can handle because that is the objective which means my program can run its ending method.
I know I could just call each method directly, but I also know from experience that if it loops too many times it will eventually crash due to taking up too much memory because the methods will never end.
If it's important none of the methods have any required output.
My current thought is that I can do a while loop, something like this:
boolean needToLoop = true;
while(needToLoop){
methodA();
}
with methodA changing needToLoop to false when it is ready to move on to methodB, but I'm not sure how to include the other methods properly.
I feel like the solution here should be simple, but I'm just not quite seeing it. If I put the other methods inside the while loop then they'll run more often than I want them, but if I put them outside the while loop, I can't revisit the loop.
