Hello,
It's been a long time since I've done some polymorhpic programming and nowI'm struggling to get my head round it again
Here's what I've got...
an interface
public interface INote
{
string note { get; set; }
}
I've 2 options dervived from this
public class Disclipinary : INote
{
public string note { get; set; }
}
public class Absence : INote
{
public string note { get; set; }
}
Now I've got the conccept of saving. So, I new up a global saver which I figured would act like delegate in order to call the right class to save it but sadly it doesn't work... or rather I'm ina pickle
public class GlobalSaver
{
public void saveMe(INote note )
{
}
}
public interface businessRules
{
void Save(INote note);
}
public class AbsenceSaver : businessRules
{
public void Save(INote note)
{
}
}
public class DisciplinarySaver : businessRules
{
public void Save(INote note)
{
}
}
And then called from main
Absence a = new Absence();
GlobalSaver saver = new GlobalSaver();
saver.saveMe(a);
What I'm after is newing up a absence or disciplinary and then saving it without having to either do a switch or a cast in order to know which save routine to call. Surely it should know which one to call based on the object?