title: Object Oriented Programming correct use interface
body: <p>I'm trying to design a few classes for a game, but I'm not sure I'm doing it right.</p>
  
  <p>I have two classes: <code>Actor</code> and <code>Building</code>.
  These have a few subclasses: <code>Policeman</code>, <code>Fireman</code> and <code>PoliceStation</code>, <code>FireStation</code>.</p>
  
  <p>I want to be able to put all these items together in a list to iterate through later, so I've added a base class: <code>GameEntity</code>. <br />
  So what I have is this:</p>
  
  <pre><code>public abstract class GameEntity: 
  {
      public GameEntity()
      {
  
      }       
  }
  
  public class Actor: GameEntity
  {
      public int _speed;
      public TileSprite _UI;
  
      public Actor()
      {
  
      }
  
      public bool CollidesWith(Vector2 pos)
      {
          //Do stuff here
      }
  
      public virtual void OnClick()
      {
          //Do stuff here
      }
  
      public void DoActing()
      {
  
      }
  }
  
  public class Policeman: Actor
  {
      public Policeman()
      {
          _speed = 10;
      }
  
      public override void OnClick()
      {
          //Do stuff
      }
  }
  
  public class Building: GameEntity
  {
      public TileSprite _UI;
  
      public Building()
      {
  
      }
  
      public bool CollidesWith(Vector2 pos)
      {
          //Do stuff here
      }
  
      public virtual void OnClick()
      {
          //Do stuff here
      }
  
      public void DoBuilding()
      {
  
      }
  }
  
  public class PoliceStation: Building
  {
      public PoliceStation()
      {
  
      }
  
      public override void OnClick()
      {
          //Do stuff
      }
  }
  </code></pre>
  
  <p>Now, I want to be able to do this:</p>
  
  <pre><code>List&lt;GameEntity&gt; Entities = new List&lt;GameEntity&gt;();
  
  Actor a1 = new PoliceMan();
  Building b1 = new PoliceStation
  
  Entities.Add(a1);
  Entities.Add(b1);
  
  foreach(GameEntity ent in Entities)
  {
      if (ent.CollidesWith(something))
      {
          ent.OnClick();
  
          //If Actor then do 
          ent.DoActing();
  
          //If Building then do
          ent.DoBuilding();
      }
  }
  </code></pre>
  
  <p>Now, in order to do the last bit, would it be best if I implement an interface that contains the <code>OnClick</code> and <code>CollidesWith</code>, or can I do it with inheritance?
  If so, how would I do this?</p>
  
  <p>Cheers.</p>