title: How can I use while loops in a text based game Java?
body: <p>So first off is just some text showing my thought process on the way the code should work. I am super new to programming in general and just started learning java only a few days ago. I think I have a basic understanding of how oop works but I can't implement it well into my code. The use of while loops makes a bit of sense to me though so I'm just starting out with those ;D</p>
  
  <p>Things I want:</p>
  
  <p>a main menu with 3 options</p>
  
  <p>Menu (camp)</p>
  
  <ol>
  <li><p>Quest (activates the quest loop)</p></li>
  <li><p>Go to Town (activates the town loop)</p></li>
  <li><p>quit game (exits the program)</p></li>
  </ol>
  
  <p>Quest
      Gameplay loop of fighting random monsters and gaining gold/score
      "monster appears"</p>
  
  <ol>
  <li><p>fight monster
          does damage to monster
          monster does damage back
          back to main loop</p></li>
  <li><p>use item
          choose item
          use item
          item effects applied
          back to main loop</p></li>
  <li><p>run
  return back to main menu (activates main menu)</p></li>
  </ol>
  
  <p>Town
  allows you to spend gold on "gear" to increase health and damage values</p>
  
  <p>"I am the blacksmith blah blah blah"</p>
  
  <ol>
  <li>Upgrade Weapon (increases damage)</li>
  <li>Upgrade Armor (increases health)</li>
  <li>Leave Town (returns player back to main menu)    </li>
  </ol>
  
  <p>Game Ends when player dies or chooses quit game</p>
  
  <p>Display a Score and thank player for playing game</p>
  
  <p>Below is just a prototype of the logic</p>
  
  <p>I feel like this should work but every time I run it,
  it doesn't work right and just ends up doing an 
  infinite loop. I'm hoping one of you guys will be able
  to see why it doesn't work and kinda steer me in the right
  direction. Anything would be greatly appreciated!</p>
  
  <p>Also any comments on those booleans for camp, dungeon, town?
  I don't know if I really needed those and its probably just
  an extra bit of useless code but I'm really not sure.</p>
  
  <pre><code>import java.util.Scanner;
  
  
  public class logic
  {
      public static void main(String[] args)
      {
  
      boolean running = true;
      Scanner in = new Scanner(System.in);
      System.out.println("This is a test");
  
      while(running)
      {
          boolean camp = true;
          boolean dungeon = false;
          boolean town = false;
          String input = in.nextLine();
          while(camp)
          {
              System.out.println("what u do?");
              System.out.println("1. go dungeon");
              System.out.println("2. go town");
              System.out.println("3. quit");
              if (input.equals("1"))
              {
                  dungeon = true;
                  while(dungeon)
                  {
                      System.out.println("you are in the dungeon");
                      dungeon = false;
                      break;
  
                  }
  
  
  
              }
              else if (input.equals("2"))
              {
                  dungeon = false;
                  town = true;
                  while(town)
                  {
                      System.out.println("you are in the town");
                      town = false;
                      break;
  
                  }
  
  
              }
              else if (input.equals("3"))
              {
                  break;
  
  
              }
              else
              {
                  System.out.println("invalid command!");
  
  
              }
  
  
          }
  
  
      }
  
      }
  
  }
  </code></pre>