title: World of Zuul: non-static method getCurrentRoom() cannot be referenced from a static context
body: <p>I know this question comes up often, but even after looking at asked question's I can't find a solution..</p>
  
  <p>So for school we have to create an own version of World of Zuul. I've implemented a beamer in it. First I put it in the Game class, but I decided it would be better to have it in it's own class, Beamer. The Beamer class looks as follows:</p>
  
  <pre><code>public class Beamer
  {
      private Room beamerRoom;
      private Room beamer;
      private int timesFired;
      private boolean beamerCharged;
  
      public Beamer(int timesFired, boolean beamerCharged)
      {
          this.timesFired = 0;
          this.beamerCharged = false;
      }
  
      public int getTimesFired()
      {
          return timesFired;
      }
  
      public Room getBeamerRoom()
      {
          return beamerRoom;
      }
  
      public boolean getBeamerCharged()
      {
          return beamerCharged;
      }
  
      public Room setBeamerRoom(Room room)
      {
          this.beamerRoom = Game.getCurrentRoom();
          return beamerRoom;
      }
  
      /**
       * Try to use beamer device. When you charge the beamer, it memorizes the current     room.
       * When you fire the beamer, it transports you immediately back to the room it was
       * charged in.
       */
      public void beamer(Command command){
          if (!command.hasSecondWord()) {
              // if there is no second word, we don't know what to do...
              System.out.println("Charge or fire beamer?");
              return;
          }
          String action = command.getSecondWord();
  
          if (action.equals("charge")) {
              if(timesFired() &lt; 1)
              {
                  beamerRoom = Game.getCurrentRoom();
                  System.out.println("This room is charged to beam!");
                  beamerCharged = true;
              }
              else
              {
                  System.out.println("The beamer has already been fired and can't be charged again");
              }
          } else if (action.equals("fire")) {
              if(beamerCharged == true)
              {    
                  if(timesFired &lt; 1)
                  {
                      Game.getCurrentRoom() = beamer.getBeamerRoom();
                      System.out.println("The beamer has succesfully been fired!");
                      System.out.println(currentRoom.getLongDescription());
                      timesFired++;
                      beamerCharged = false;
                  }
                  else
                  {
                      System.out.println("You can only fire the beamer once!");
                  }
              }
              else
              {
                  System.out.println("The beamer hasn't been charged yet!");
              }
          } else {
              System.out.println("Invalid beamer command!");
              return;
          }
      }
  }
  </code></pre>
  
  <p>I get the error <code>method getCurrentRoom() cannot be referenced from a static context</code> here:
  <code>beamerRoom = Game.getCurrentRoom();</code></p>
  
  <p>The method in Game to get the current room is as follows:</p>
  
  <pre><code>public Room getCurrentRoom()
      {
          return currentRoom;
      }
  </code></pre>
  
  <p>Very simple, which in my mind should work.</p>
  
  <p>How can I solve this issue? I've looked around but can't find a fix that works..</p>
  
  <p>If you need more of the Game class code, please ask. I didn't post it here since it's 300+ lines.</p>
  
  <p>EDIT:
  I already found what I did wrong. By using <code>Game.getCurrentRoom</code> it looked at the class Game, rather than an object of the Game. At least that's what I think went wrong. I had the error message with more methods, using capital letters (<code>Game.&lt;method&gt;</code>), <code>Player.&lt;method&gt;</code>), but when I didn't use the capital letters (<code>game.&lt;method&gt;</code>), <code>player.&lt;method&gt;</code>) it worked fine.</p>
  
  <p>So I guess the problem is solved.</p>