private static void Events() { var tower = new ClockTower(); var peniel = new Person("Peniel", tower); var twitter = new Person("Twitter", tower); tower.ChimeFivePm(); tower.ChimeSixAm(); }
public Person(string name, ClockTower tower) { _name = name; _tower = tower; _tower.Chime += (object sender, ClockTowerEventArgs args) => { Console.WriteLine($"{name} heard the clock chime."); switch (args.Time) { case 6: Console.WriteLine($"{name} is waking up"); break; case 17: Console.WriteLine($"{name} is going home"); break; } }; }