This week's book giveaways are in the Jython/Python and Object-Oriented programming forums. We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line! See this thread and this one for details.
I am using switch to allow the user to chose items from a menu and I have all items working except my quit. I have
boolean finished = false;
int decision = getUserInt(userResponse);
case 1: createANewFleet();
case 2: addATruck();
case 3: fillAllTrucks();
case 4: displayFleetToString();
case 5: finished = true;
userResponse = scan.nextLine();
System.out.println("This will end your current session. Goodbye!");
the problem is.. I have to press 5 twice in order to exit. Any suggestions?
I do see that. The thing is, i have a "priming" print menu and then after the user makes a decision and the case breaks the menu has to appear again and the the user has to make another choice. The only time this is not necessary is when I am quitting the program. When I press 5 the second time the program terminates and the goodbye message prints. I'm just trying to find a way to jump to the beginning of the loop right after the boolean value is changed so that the program bypasses the while loop (since it should now be closed) and the ending message prints right away.
posted 7 years ago
got it! I just moved some things around...
So I left, I came home, and I ate some pie. And then I read this tiny ad: