In college I got task to do. I have simple program like below. I have one parent class who represent person, and few child which inherit from it and represent role(Archer, Knight, Wizzard). I must implemented funcionality to easy switching object type, from Archer to Knight and so on. At first I thought about creating a large interface with all the unique methods, but it breaks the SOLID rule, but I can't break this rule. Could someone help figure it out?
This is how look code:
public abstract class Person
{
public String Name;
public char Age;
void describe()
{
//some code
}
}
Role class:
public class Archer : Person
{
public int agility;
public void describe()
{
//some code
}
public void fightUsingBow()
{
//some code
}
}
Next role:
class Wizzard : Person
{
public int mana;
public void describe()
{
//some code
}
public void castASpell()
{
//some code
}
}