I have three types of Persons:
Class Normal
{
string FirstName { get; set; }
int Age { get; set; }
}
Class Better
{
string FirstName { get; set; }
int Age { get; set; }
}
Class Best
{
string FirstName { get; set; }
int Age { get; set; }
string Address { get; set; }
int Score { get; set; }
}
what is the best way to put them in one list? I myself came up with:
public enum PersonType
{
Normal = 0,
Better = 1,
Best = 2
}
public interface IPerson
{
PassengerType Type { get; set; }
string FirstName { get; set; }
int Age { get; set; }
}
And then
public class Person:IPerson
{
public PassengerType Type { get; set; }
public string FirstName { get; set; }
public int Age { get; set; }
}
which I can use it for both Normal and Better and I can make distiction by type and
public class Best:IPerson
{
public PassengerType Type { get; set; }
public string FirstName { get; set; }
public int Age { get; set; }
public string Address { get; set; }
public int Score { get; set; }
}
and eventually: List ....
Is this a good design? what if a 'best' instance is created, but type is set to Normal. would it be a bad design?
Aucun commentaire:
Enregistrer un commentaire