title: While loop not checking both conditions?
body: <p>I am fairly new to programming and have decided to take on a project where I create a game in the console. The user has the options to move up, down, left, or right from the center of an area that is a 3x3 grid. One of the x,y locations is marked a 'bad' square and the game ends when the user's x and y are equal to that of the bad square's. The bad squares location is <code>x = 1</code> and <code>y = 3</code>.</p>
  
  <p>The problem I have is that when the user enters Up or Left (hence the users y becomes 3 or the users x becomes 1) and the game ends even though one of the other axis values does not match the bad squares. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>public static void main (String[]args){
      //scanner
      Scanner userIn = new Scanner(System.in);
  
      //string that will get users value
      String movement;
  
      //strings that are compared to users to determine direction
      String up = "Up";
      String down = "Down";
      String left = "Left";
      String right = "Right";
  
      //starting coordinates of user
      int x = 2;
      int y = 2;
  
      //coordinates of bad square
      int badx = 1;
      int bady = 3;
  
      //message telling user options to move (not very specific yet)
      System.out.println("Up, Down, Left, Right");
  
      //do while loop that continues until 
      do {
          movement = userIn.nextLine();
  
          //checking user input and moving them accordingly
          if (movement.equals(up)) {
              y++;
          } else if (movement.equals(down)) {
              y--;
          } else if (movement.equals(left)) {
              x--;
          } else if (movement.equals(right)) {
              x++;
          } else {
              System.out.println("Unacceptable value");
          }
  
          //checking if user is out of bounds, if user tries to leave area, x or y is increased or decreased accordingly
          if (x &lt; 0 || y &lt; 0 || x &gt; 3 || y &gt; 3) {
              System.out.println("Out of bounds");
              if (x &lt; 0) {
                  x++;
              } else if (y &lt; 0) {
                  y++;
              } else if (x &gt; 3) {
                  x--;
              } else if (y &gt; 3) {
                  y--;
              }
          }
          //message showing user x and y coordinates
          System.out.println("x =" + x + " y =" + y);
      } while (y != bady &amp;&amp; x != badx); //what checks to see if user has come across the bad square
  
      //ending message (game ends)
      System.out.println("Bad Square. Game over.");
  }
  </code></pre>