Esempio n. 1
0
        static void Main(string[] args)
        {
            Car car = new Car("AA2233F");
            Car carNumber2 = new Car("BF5533A");
            Policeman policeman = new Policeman(90);

            car.CurrentSpeedChanged += CurrentSpeedChangedEventHandler;
            carNumber2.CurrentSpeedChanged += CurrentSpeedChangedEventHandler;

            car.CurrentSpeedChanged += policeman.CheckCurrentSpeed;
            carNumber2.CurrentSpeedChanged += policeman.CheckCurrentSpeed;

            for (int i = 0; i < 17; i++)
            {
                car.SpeedUp(i);
                carNumber2.SpeedUp(1);
            }
            Console.WriteLine("Before sleep");
            System.Threading.Thread.Sleep(5000);
            Console.WriteLine("After sleep");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Car       car        = new Car("AA2233F");
            Car       carNumber2 = new Car("BF5533A");
            Policeman policeman  = new Policeman(90);

            car.CurrentSpeedChanged        += CurrentSpeedChangedEventHandler;
            carNumber2.CurrentSpeedChanged += CurrentSpeedChangedEventHandler;

            car.CurrentSpeedChanged        += policeman.CheckCurrentSpeed;
            carNumber2.CurrentSpeedChanged += policeman.CheckCurrentSpeed;

            for (int i = 0; i < 17; i++)
            {
                car.SpeedUp(i);
                carNumber2.SpeedUp(1);
            }
            Console.WriteLine("Before sleep");
            System.Threading.Thread.Sleep(5000);
            Console.WriteLine("After sleep");
        }