static void Main(string[] args) { Console.WriteLine("This program uses delegates and simulates persons behavior, when every single person come and leave office." + "\nHere is an axample:\n\n"); List <Person> employees = new List <Person>(); Person Alex = new Person("Alex"); Person Dave = new Person("Dave"); Person George = new Person("George"); Person Jane = new Person("Jane"); employees.Add(Alex); employees.Add(Dave); employees.Add(George); employees.Add(Jane); Office office = new Office(employees); Alex.ComeToOffice(); Dave.ComeToOffice(); George.ComeToOffice(); Jane.ComeToOffice(); Jane.LeaveOffice(); Alex.LeaveOffice(); George.LeaveOffice(); Console.WriteLine("Dave died."); Console.ReadKey(); }
static void Main(string[] args) { var office = new Office(); var p1 = new Person("Дима"); var p2 = new Person("Илья"); var p3 = new Person("Андрей"); office.AddPerson(p1); office.AddPerson(p2); office.AddPerson(p3); p1.EnterToOffice(); p2.EnterToOffice(); p3.EnterToOffice(); p2.LeaveOffice(); p1.LeaveOffice(); p3.LeaveOffice(); }