Question: I am trying to solve a simple OOPs problem. When I have to create few weapons and each weapon has a primary action and that primary action can be performed by a mouse click. Example for a shotgun it is shooting and for Katana is swinging it. Below my classes are.

```
public interface IShootable
{
    void TakeShot();
}
public interface ISwingable
{
    void Swing ();
}

public class ShotGun : IShootable
{
    public void TakeShot()
    {
    }
}
public class Kanata : ISwingable
{
    public void Swing ()
    {
    }
}   

```

Each weapon has implemented different interface for their primary actions. (I'm not sure that I can create an abstract class, from which I can inherit these concrete classes. It seems not substitutable for two different type of weapons.)

What I wanted to achieve is in runtime when user selects one of the weapons, the user gets the right action on mouse click. For shotgun it is `TakeShot()` and for Katana it is `Swing()`.

What I have to do adopt that. Or I should restructure the classes in some other way.

Answer: 
You might want to do something more generic:

```
public interface IWeaponPrimaryAction
{
    void PerformPrimaryAction();
}
public interface IWeaponAction
{
    void PrimaryAction();
}

public class Shoot :IWeaponAction
{
    public void PrimaryAction()
    {
        //Fire in the hole
    }
}   
public class Swing :IWeaponAction
{
    public void PrimaryAction()
    {
        //Into pieces
    }
}
public class ShotGun : IWeaponPrimaryAction
{
    private IWeaponAction _action = new Shoot();
    public void PerformPrimaryAction()
    {
        _action.PrimaryAction();
    }
}
public class Kanata : IWeaponPrimaryAction
{
    private IWeaponAction _action = new Swing();
    public void PerformPrimaryAction()
    {
        _action.PrimaryAction();
    }
}

```

Better than that just inject the action:

```
public class ShotGun : IWeaponPrimaryAction
{
    private IWeaponAction _action;
    public ShotGun(IWeaponAction action)
    {
        _action = action;
    }
    public void PerformPrimaryAction()
    {
        _action.PrimaryAction();
    }
}

```
My preference would be what @Riki suggests and create an interface that all weapons inherit `IWeapon` with a single method `IWeapon.PerformPrimaryAction()`. However if you don't like that you could create a "base" interface that all weapon interfaces derive from, then at runtime use casting, `is` or `as` to determine which weapon you have:

```
public interface IWeapon {};

public interface IShootable : IWeapon
{
    void TakeShot();
}

public interface ISwingable : IWeapon
{
    void Swing ();
}

public partial class YourGameClass
{
    public void DoTheAction (IWeapon weapon)
    {
        if (weapon is IShootable)
            (weapon as IShootable).TakeShot();
        if (weapon is ISwingable)
            (weapon as ISwingable).Swing();
    }
}

```