Exemple #1
0
 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} is waking up.", _name);
                 break;
             case 17: Console.WriteLine("{0} is going home.", _name);
                 break;
         }
     };
 }
Exemple #2
0
        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} is waking up", _name);
                    break;

                case 17:
                    Console.WriteLine("{0} is going home from work", _name);
                    break;
                }
            };
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var tower = new ClockTower();
            var john = new Person("John", tower);

            tower.ChimeSixAM();

            Console.ReadLine();
        }