If this helps, the next question arises in the context of the game I am creating.
In several different places, I have the following scenario. There is a parent class, called Skill for this example, and I have several subclasses that implement methods from the parent class. There is also another parent class, which we will call Vocation. Skills must be listed in different subclasses of Vocation. However, these skills must be available for anything in a game that uses any task.
My current setup is to have an Enum called Skill.Id, so Vocation contains a set of values from this Enum and when the object in the game accepts this Vocation, the collection is passed to another class called SkillFactory. Skill.Id requires a new entry each time I create a new subclass of the Skill class, as well as a case in the switch block for a new subclass constructor.
i.e:.
Enum{FireSkill,WaterSkill,etc}
public static Skill Create(Skill.Id id)
{
switch(id)
{
case Skill.Id.FireSkill:
return new FireSkill();
}
}
This works fine, but using an enumerated and a commutation block, as a transition between feelings, as more overhead than I need to solve this problem. Is there a more elegant way to instantiate these Skill subclasses, but still allows Vocation to contain a collection that identifies the skills that it can use?
: , Vocation , Skill.