If there are 3 interfaces like the following
public interface IWeapon {
void Kill();
}
public interface ISword:IWeapon {
void Slice();
}
public interface IShuriken: IWeapon {
void Pierce();
}
public class Ninja {
public IWeapon Weapon {get;set;}
public void BrutalKill() {
/* warrior must pierce, pierce, pierce and then kill
*/
}
public void HonorKill {
/* warrior must kill by one slice */
}
}
For a scenario like this how would you wireup the container and what would your method body look like for BrutalKill and HonorKill ?
EDIT: Based on comments, I was thinking on the lines a ninja should be armed with a weapon… if it wants to be armed with a sword or shuriken…should be decided later… not sure if i am thinking right .. maybe we need to subclass Ninja as NinjaWithShuriken and NinjaWithSword
Not sure if this is what you are looking for, but I would have this:
Update
I like Phil Sandler’s comment so a quick update to reflect that:
Update
Based on the update to the original question I would say:
The idea being that we don’t really care how Sword and Shuriken implement Attack, as long as the ninja can use them to perform his duty when called upon. The assassination can be caried out how the specific ninject wishes, as long as the job gets done within the confines of the stated agreement, in this case by Attacking.