public enum PreferedContatWay { Sms, Email, Lms }
public int Id { get; set; }
public PreferedContatWay ContactMethod { get; set; }
public Notify(ISendable s)
public List<Student> students;
foreach (var student in students)
var factoredObj = FactoryObjecCreator(student);
var notify = new Notify(factoredObj);
ISendable FactoryObjecCreator(Student student)
=> student.ContactMethod.ToString() switch
nameof(Email) => new Email(student),
nameof(Sms) => new Email(student),
nameof(Lms) => new Email(student),
_ => throw new NotImplementedException()
public interface ISendable
public int Send(string message);
public class Sms : ISendable
public Sms(Student student)
public int Send(string message)
throw new NotImplementedException();
public class Email : ISendable
public Email(Student student)
public int Send(string message)
throw new NotImplementedException();
public class Lms : ISendable
public Lms(Student student)
public int Send(string message)
throw new NotImplementedException();