title: How to move a Bug in GridWorld with arrow keys
body: <p>I'm making a game for my computer Science class and I am trying to move a character object that extends Bug with the arrow keys.  Should I put the code to move with the arrow keys in the Character class or in the World class? And what should the code look like? Right now I've got this code in the Character class and it complies fine, but when I try to to run it in the grid nothing happens when I press the arrow keys. </p>
  
  <pre><code> public class Character extends Bug
  {
  Random pokemon;
  public Character()
  {
  
  }
  
  public void act(KeyEvent e)
  {
          move(e);
          pokemon = new Random();
          if(pokemon.nextInt(10) == 5)
              System.out.println("It works!!");
  }
  
  public void move(KeyEvent e)
  {
      Grid&lt;Actor&gt; gr = getGrid();
      Location loc = getLocation();
      if(gr == null)
          return;
      if( e.getKeyCode() == KeyEvent.VK_RIGHT)
      {
          if(!(getDirection() == 90))
              setDirection(90);
          else
          {
  
              Location next = loc.getAdjacentLocation(getDirection());
              if (gr.isValid(next))
                  moveTo(next);
              else
                  removeSelfFromGrid();
          }
      }
      else if( e.getKeyCode() == KeyEvent.VK_LEFT)
      {
          if(!(getDirection() == 270))
              setDirection(270);
          else
          {
  
              Location next = loc.getAdjacentLocation(getDirection());
              if (gr.isValid(next))
                  moveTo(next);
              else
                  removeSelfFromGrid();
          }
      }
      else if( e.getKeyCode() == KeyEvent.VK_UP)
      {
          if(!(getDirection() == 0))
              setDirection(0);
          else
          {
  
              Location next = loc.getAdjacentLocation(getDirection());
              if (gr.isValid(next))
                  moveTo(next);
              else
                  removeSelfFromGrid();
          }
      }
      else if( e.getKeyCode() == KeyEvent.VK_DOWN)
      {
          if(!(getDirection() == 180))
              setDirection(180);
          else
          {
  
              Location next = loc.getAdjacentLocation(getDirection());
              if (gr.isValid(next))
                  moveTo(next);
              else
                  removeSelfFromGrid();
          }
      }
  
  public class Character extends Bug
  {
  Random pokemon;
  public Character()
  {
  
  }
  
  public void act(KeyEvent e)
  {
          move(e);
          pokemon = new Random();
          if(pokemon.nextInt(10) == 5)
              System.out.println("It works!!");
  }
  
  public void move(KeyEvent e)
  {
      Grid&lt;Actor&gt; gr = getGrid();
      Location loc = getLocation();
      if(gr == null)
          return;
      if( e.getKeyCode() == KeyEvent.VK_RIGHT)
      {
          if(!(getDirection() == 90))
              setDirection(90);
          else
          {
  
              Location next = loc.getAdjacentLocation(getDirection());
              if (gr.isValid(next))
                  moveTo(next);
              else
                  removeSelfFromGrid();
          }
      }
      else if( e.getKeyCode() == KeyEvent.VK_LEFT)
      {
          if(!(getDirection() == 270))
              setDirection(270);
          else
          {
  
              Location next = loc.getAdjacentLocation(getDirection());
              if (gr.isValid(next))
                  moveTo(next);
              else
                  removeSelfFromGrid();
          }
      }
      else if( e.getKeyCode() == KeyEvent.VK_UP)
      {
          if(!(getDirection() == 0))
              setDirection(0);
          else
          {
  
              Location next = loc.getAdjacentLocation(getDirection());
              if (gr.isValid(next))
                  moveTo(next);
              else
                  removeSelfFromGrid();
          }
      }
      else if( e.getKeyCode() == KeyEvent.VK_DOWN)
      {
          if(!(getDirection() == 180))
              setDirection(180);
          else
          {
  
              Location next = loc.getAdjacentLocation(getDirection());
              if (gr.isValid(next))
                  moveTo(next);
              else
                  removeSelfFromGrid();
          }
      }
  </code></pre>
  
  <p>Is this code correct for a KeyEvent and how can I call on this code from the World class?
  Any help would be greatly appreciated!</p>