public class University
{
public delegate void GrantScholarshipDelegate();
public event GrantScholarshipDelegate GrantScholarship;
public void AddStudent(Student student)
{
GrantScholarship += student.GetScholarship;
}
private void OnGrantScholarship()
{
GrantScholarship?.Invoke();
}
public void TimeToSendScholarship()
{
OnGrantScholarship();
}
}
public class Student
{
public string Name { get; set; }
public void GetScholarship()
{
Console.WriteLine($"Student {Name} has received scholarship!");
}
}
class Program
{
static void Main(string[] args)
{
University university = new University();
university.AddStudent(new Student() { Name = "Max" });
university.TimeToSendScholarship();
Console.ReadKey();
}
}
Comments
Leave a comment