public Person(string name, ClockTower tower) { this.name = name; this.tower = tower; tower.Chime += (object sender, ClockTowerEventArgs args) => { Console.WriteLine("{0} heard the clock time !", this.name); switch (args.Time) { case 6: Console.WriteLine("{0} is waking up.", this.name); break; case 17: Console.WriteLine("{0} is going back home.", this.name); break; } }; }
public Person(string name, ClockTower tower) { _name = name; _tower = tower; _tower.chime += (object sender, ClockTowerEventArgs args) => { Console.WriteLine("{0} Heard the clock chime", _name); switch (args.Time) { case 6: Console.WriteLine("{0} This person is going up", _name); break; case 17: Console.WriteLine("{0} This person is going home", _name); break; } }; }
//konstruktor public Person(string name, ClockTower tower) { _name = name; _tower = tower; //in parenthis must be the 2 arguments from the delegate _tower.Chime += (object sender, ClockTowerEventArgs args) => { Console.WriteLine("{0} heard the clock chime.", _name); switch (args.Time) { case 6: Console.WriteLine("{0} is waking up", _name); break; case 17: Console.WriteLine("{0} is going home.", _name); break; } }; }
public Person(string name, ClockTower tower) { _name = name; _tower = tower; }