static void Main(string[] args) { var tower = new ClockTower(); var john = new Person("John", tower); tower.Chime += (s, e) => { Console.WriteLine("{0} : heard the clock chime.", john.GetName()); switch (e.message) { case 6: Console.WriteLine("{0} is wakking up!", john.GetName()); break; case 17: Console.WriteLine("{0} is going home!", john.GetName()); break; } }; tower.ChimeAtSixAm(); tower.ChimeAtFivePm(); Console.ReadKey(); }
public Person(string Name, ClockTower Tower) { this._name = Name; this._tower = Tower; }