What is the simplest way to change the behavior of a method during runtime?
<p>I have class called <code>Enemy</code>, and I want to have multiple types of enemies. Each <code>Enemy</code> will have different movement behavior, for example one might move straight at the player, one might maintain a certain distance, etc. What I would like to know is, what is the simplest way to have multiple different behaviors, preferably in one class?</p>

<p>My current idea is to use a <code>switch</code>, and include all the behavior in one method</p>

<pre><code>public class Enemy
{
     public int health;
     public int damage;
     // etc etc

     public void Move(string type)
     {
        switch(type)
        {
             case "charge":
                  chargeMove();
                  break;
             case "maintain":
                  maintainMove();
                  break;
        }
     }

     private void chargeMove()
     {
          //stuff
     }

     private void maintainMove()
     {
          //stuff
     }

     //all the behaviors
}
</code></pre>

<p>What I would like to know, is it better to keep everything to one function like this, or to create a new class for each enemy type that inherits from <code>Enemy</code>? I would prefer to keep it to one class, so that all the enemies can be nicely stored into a <code>IList</code>, without me having to do any casting to use any of the specific functions.</p>

<p>Any advice would be appreciated.</p>

<p>EDIT: Thanks for all the responses, I think that I will use the interface method proposed by Alastair.</p>
