Beispiel #1
0
        static void Laba8Test()
        {
            Console.WriteLine("Lets create Tesla model S:");

            ElectricCar tesla = new ElectricCar("Tesla S", DateTime.Now, CarType.Crossover, DriveType.FourWhell);

            tesla.Engine = new Engine(EngineType.electric, 300, 0);

            Console.WriteLine("Let's give the car a few tasks: turn on engine, turn off engine and unlock the doors:");

            tesla.tasks += delegate(ElectricCar ecar)
            {
                ecar.TurnEngineOn();
            };

            tesla.tasks += delegate(ElectricCar ecar)
            {
                ecar.TurnEngineOff();
            };

            tesla.tasks += (ElectricCar ecar) =>
            {
                ecar.UnlockDoors();
            };

            Console.WriteLine("Let the car complete the tasks:");

            tesla.PerformTasks();
        }