title: Get static variable of subclass given superclass
body: <p>This was very difficult for me to word into a question so allow me to explain.</p>
  
  <p>I have an abstract class <code>Entity</code> and subclasses <code>House</code> and <code>Warehouse</code>. Each subclass has the same static variables with different values. </p>
  
  <p>When a button is pressed in my game an <code>Action</code> is created which specifies which Entity subclass gets created and placed in the world. I want to write a generic method to place some <code>Entity</code> to the world using the static variables of which ever subclass it is. </p>
  
  <p>I have a class <code>PlaceEntityAction</code> and when the mouse is clicked the appropriate entity will be placed assuming conditions are correct. How can I pass the Class I want to be placed to this Action so it works with any generic <code>Entity</code>?</p>
  
  <p>Here is some dumbed down code:</p>
  
  <pre><code>if (mousePressed)) {
      if (some conditions are true) {
  
          int ex = x pos
          int ey = y pos
  
  
          if (world.player.haveFunds(e.COST_ENERGY, e.COST_MONEY,
                      e.COST_RESOURCE)) {
              if (world.places[ex][ey] == 0) {
                  world.entities.add(e);
                  world.player.addEnergy(-e.COST_ENERGY);
              }
          }
      }
  }
  </code></pre>
  
  <p>So basically how can I get that <code>e</code> to be whatever subclass I pass to the Action since COST_MONEY, etc is static and should be accessed by the Class and not an object?</p>
  
  <p>I'm really struggling to express what I want. Maybe someone can decipher this or provide some other insight regarding my issue. I can provide any other information necessary if you want.</p>
  
  <p>EDIT:</p>
  
  <p><code>e</code> is an instance of whichever subclass I previously initialized based on an ID system but I don't like this method. </p>