title: How to instantiate a certain subclass depending on an identifier, or is there a better way?
body: <p><strong>Background:</strong><br>
  I am currently working on a game, in which there will be several types of furniture such as chairs, tables or paintings for the player to interact with. For this I have created an abstract class <code>GameObject</code> that handles everything all these objects will have in common (such as drawing, holding position variables etc.). The furniture pieces will have a few parameters that differs, such as width and height (integers) and also what happens when the user choose to interact with it (for example: chairs -> if player is close, sit down, tables -> nothing, paintings -> examine independent of distance). Furniture can be created from a menu, that returns some kind of identifier for the selected piece (currently an integer).</p>
  
  <p><strong>The Question:</strong><br>
  How should I implement the different pieces of furniture?<br>
  One way would be to create a subclass for each piece of furniture. But this has two drawbacks; First it will be hard to manage that many classes, and secondly when the furniture is created, the correct subclass of GameObject will somehow have to be created based on the identifier (see the followup question).  </p>
  
  <p>The most logical option to me seems to be to create a general class that takes the width and height parameters in the constructor as well as a runnable/other interface that can be run when the user clicks on the object. The different values could possibly be stored in a database and retrieved based on the identifier, but the problem still arises with the different actions, since the Runnables cannot be stored externally, and that leads back to the same problem as solution 1; Many different classes where one has to be chosen for the current object.  </p>
  
  <p><strong>Followup Question:</strong>
  Depending on the types of furniture and actions it seems possible that more advanced subclasses with additional methods might be required. If so, the problem of choosing which one to implement depending on an identifier remains regardless of the solution to the previous question. I don't want to use a gigantic switch statement to instantiate different classes, so is there any way around this?</p>
  
  <p><em>The game is for the Android platform, but there might be  future IOS port, so java-specific answers is not preferable, but acceptable.</em></p>