Question 1:
There are several options:
Make
GotLegs
an extension method forIPerson
:public static class PersonExtensions { public static bool GotLegs(this IPerson person) { return true; } }
In that case,
IPerson
shouldn't defineGotLegs
itself.Add
GotLegs
to theIPerson
interface and create a base classPersonBase
that implements this method and makeCityPeople
andVillagers
derive from that base class.
Question 2:
Simple make GetPeople
and Factory
static:
public static class Factory
{
public static IPeople GetPeople(PeopleType type)
{
...
}
}
Usage would be just as you showed:
IPeople people = Factory.GetPeople(PeopleType.URBAN);