title: How to make a Counter?
body: <p>I've got a OOP project, where I have to program the action of critters in a grid.</p>
  
  <p>This is what I have now.</p>
  
  <pre><code>public class Frog implements Critter {
      //below is what letter represents the Frog in the grid.  Works fine.
      public char getChar() {
          return 'F';
      }
  
  public int getMove(CritterInfo info) {
      //need to count the moves to determine how far to move
      int countF;
      countF++;
      int moveF2 = 0;
      if (countF % 3 == 1) {
          int moveF = (int)(Math.random() * 100);
          moveF2 = moveF;
          countF = 0;
      } 
      else {
          if (moveF2 &lt; 25) {
              return NORTH;
          }
          else if (moveF2 &lt; 50) {
              return SOUTH;
          } 
          else if (moveF2 &lt; 75) {
              return EAST;
          }
          else {
              return WEST;
          }
      }
  }
  </code></pre>
  
  <p>The Frog is supposed to pick a random direction, moves 3 in that direction, repeat.</p>
  
  <p>I don't know how to make a counter to count the amount of moves.  I thought about:</p>
  
  <pre><code>public int getMove(CritterInfo info) {
      int countF = 0;
      countF++;
      int moveF2 = 0;
      if (countF % 3 == 1) {
          int moveF = (int)(Math.random() * 100);
          moveF2 = moveF;
          countF = 0;
      }
      else {
          ...(cut)
      }
   }
  </code></pre>
  
  <p>But the above obviously doesn't work because it resets countF to 0 every time it gets run.</p>