title: 2D grid movement checking
body: <p>The purpose of the program is to generate a two-dimensional grid array made of periods ( . ). The user designates a starting point for the 'walker' which is marked by 'A', and then the walker will generate numbers from 0-3 to represent the four cardinal directions. It will move in these random directions while incrementing the alphabet with each mark it leaves until it either runs in to the wall and is "arrested" or reaches 'Z' at which it "made it home". If it runs in to a space it has already been to, it has to jump ahead in the same direction until it reaches an empty space or hits the wall.</p>
  
  <p>My problem now is that I have it on a counter to make sure it doesn't run past 'Z', and will "make it home" if it reaches that point. But even the movements that it is taking to avoid overwriting where it has already been are registering on the counter (which they shouldn't be), so its returning true even though it hasn't hit Z yet, and its also still calling my random number generator so its not keeping to the same direction when it tries to correct itself. It also seems to be occasionally even jumping over empty spaces.</p>
  
  <p>The problem is in processing()</p>
  
  <pre><code>package walktester;
  
  import java.lang.Math;
  import java.util.Random;
  import java.util.Scanner;
  
  class DrunkWalker {
      private char[][] walkgrid = new char[10][10];
      private static int randNSEW;
      private int randomnum;
      private int startrow;
      private int startcol;
      private char alpha = 'A';
      private int nextrow;
      private int nextcol;
  
      public DrunkWalker(int r, int c) {
          startrow = r;
          startcol = c;
          nextrow = startrow;
          nextcol = startcol;
  
          for (int i = 0; i &lt; 10; i ++) {
              for (int j = 0; j &lt; 10; j++)
                  walkgrid[i][j] = '.';
          }
          walkgrid[r][c] = alpha++;
      }
  
      public static void getRand(){
          int x100 = 0;
          double randomNum = 0.0;
          randomNum = Math.random();
          x100 = (int) (randomNum * 100);
          randNSEW = x100 % 4;
      }
  
      public int getNextRow(){
          return nextrow;
      }
  
      public int getNextCol(){
          return nextcol;
      }
  
      public boolean processing(){
      for(int i = 1; i &lt; 26; i ++){
          getRand();
          if(randNSEW == 0){
              nextcol--;
          }
          if(randNSEW == 1){
              nextrow++;
          }
          if(randNSEW == 2){
              nextcol++;
          }
          if(randNSEW == 3){
              nextrow--;
          }
  
          if(nextrow &lt; 0 || nextrow &gt;= 10 || nextcol &lt; 0 || nextcol &gt;= 10) {
              return false;
          }
          if(randNSEW == 0 &amp;&amp; walkgrid[nextrow][nextcol] != '.'){
              nextcol--;
              continue;
          }
          if(randNSEW == 1 &amp;&amp; walkgrid[nextrow][nextcol] != '.'){
              nextrow++;
              continue;
          }
          if(randNSEW == 2 &amp;&amp; walkgrid[nextrow][nextcol] != '.'){
              nextcol++;
              continue;
          }
          if(randNSEW == 3 &amp;&amp; walkgrid[nextrow][nextcol] != '.'){
              nextrow--;
              continue;
          }
  
          walkgrid[nextrow][nextcol] = alpha++;
      }
      return true;
  }
  
  
  
  
      public char[][] DisplayGrid() {
      for(int y = 0; y &lt; 10; y++) {
          for(int x = 0; x &lt; 10; x++) {
              System.out.print(walkgrid[x][y] + " ");
          }
          System.out.println();
      }
      return walkgrid;
  }
  }
  
  public class WalkTester {
  
      public static void main(String[] args) {
          Scanner inpr = new Scanner(System.in);
          Scanner inpc = new Scanner(System.in);
          Scanner inpchoice = new Scanner(System.in);
  
          int r = 0;
          int c = 0;
          char choice = 'y';
  
          while(choice == 'y' || choice == 'Y') {
              System.out.println("Please enter x coordinate between 1 and 10.");
              r = inpr.nextInt();
              r = r - 1;
  
              System.out.println("Please enter y coordinate between 1 and 10");
              c = inpr.nextInt();
              c = c - 1;
  
              if(r &lt; 0 || r &gt; 9 || c &lt; 0 || c &gt; 9){
                  System.out.println("Invalid Entry. Restart? y/n");
                  choice = inpchoice.next().charAt(0);
                  if(choice == 'y' || choice == 'Y'){
                      continue;
                  }
                  else if(choice == 'n' || choice == 'N'){
                      return;
                  }
                  else{
                      System.out.println("Invalid Entry. Restart? y/n");
                      choice = inpchoice.next().charAt(0);
                  }
              }
              DrunkWalker drunkwalker = new DrunkWalker(r, c);
              boolean walkerSucceeded = drunkwalker.processing();
              drunkwalker.DisplayGrid();
              if(walkerSucceeded) {
              System.out.println("You made it home");
              } else {
              System.out.println("You were arrested");
              }
  
              System.out.println("Restart? y/n");
              choice = inpchoice.next().charAt(0);
              if(choice == 'y' || choice == 'Y'){
                  continue;
              }
              else if(choice == 'n' || choice == 'N'){
                  return;
              }
              else{
                  System.out.println("Invalid Entry. Restart? y/n");
                  choice = inpchoice.next().charAt(0);
              }
          }
      }
  }
  </code></pre>