/// <summary> /// Приветствие в зависимости от текущего времени. /// </summary> public void Greeting(Office anotherPerson) { string greet; if (DateTime.Now.Hour < 12) greet = "Доброе утро"; else if (DateTime.Now.Hour < 17) greet = "Добрый день"; else greet = "Добрый вечер"; Console.WriteLine("''{0}, {1}!'', - сказал {2}.", greet, anotherPerson, this); }
/// <summary> /// Сотрудник уходит домой /// </summary> public static void GoHome(Office name) { Console.WriteLine("[{0} ушёл домой.]", name); OnCameToWork -= name.Greeting; OnGoHome -= name.Farewell; if (OnGoHome != null) OnGoHome(name); Console.WriteLine(); }
/// <summary> /// Сотрудник приходит на работу /// </summary> public static void CameToWork(Office name) { Console.WriteLine("[На работу пришёл {0}]", name); if (OnCameToWork != null) OnCameToWork(name); OnCameToWork += name.Greeting; OnGoHome += name.Farewell; Console.WriteLine(); }
static void Main(string[] args) { Office jhon = new Office("Джон"); Office hugo = new Office("Хьюго"); Office bill = new Office("Билл"); Office.CameToWork(jhon); Office.CameToWork(hugo); Office.CameToWork(bill); Office.GoHome(jhon); Office.GoHome(hugo); Office.GoHome(bill); Console.Write("Нажмите любую клавишу для закрытия программы."); Console.ReadKey(); }
static void Main(string[] args) { Office jhon = new Office("Джон"); Office hugo = new Office("Хьюго"); Office bill = new Office("Билл"); Office.CameToWork(jhon); Office.CameToWork(hugo); Office.CameToWork(bill); Office.GoHome(jhon); Office.GoHome(hugo); Office.GoHome(bill); Console.ReadKey(); }
static void Main(string[] args) { var office = new Office(); Person.CameEvent += office.OnCame; Person.LeftEvent += office.OnLeft; var john = new Person("Джон"); john.Came(10.05); var bill = new Person("Билл"); bill.Came(12.50); var hugo = new Person("Хьюго"); hugo.Came(17.10); john.Left(); bill.Left(); hugo.Left(); Console.ReadKey(); }
public void CameInOffice(DateTime time) { Office office = new Office(); office.CameInOffice(this, time); }
public void LeftFromOffice() { Office office = new Office(); office.LeftFromOffice(this); }
/// <summary> /// Прощание /// </summary> public void Farewell(Office anotherPerson) { Console.WriteLine("''До свидания, {0}!'', - сказал {1}.", anotherPerson, this); }
/// <summary> /// Прощание /// </summary> public void Farewell(Office anotherPerson) { Console.WriteLine("'До свидания, {0}!', - сказал {1}.", anotherPerson, this); }