View Single Post
  #3 (permalink)  
Old 02-10-2008, 09:53 PM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Boolean variables
Hello Cero.Uno

You can solve this problem simply by using boolean variables. The String.equals() method returns a boolean result of true if your Strings are equal in value.
Code:
boolean loop = true; do{ userChoice = getInput("Please make a selection"); boolean quit = userChoice.equals("q"); boolean play = userChoice.equals("p"); loop = (quit || play) == false; while (loop == true);
This code uses the logic operators || and ==. Google logic operators in Java, to find out more.

Good luck.
__________________
If your ship has not come in yet then build a lighthouse.
Reply With Quote