Esempio n. 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();
        }
Esempio n. 2
0
        static void Laba6Test()
        {
            Console.WriteLine("Lets create 3 cars:");

            Car car1 = new BMW("BMW X6", CarType.Crossover, DriveType.FourWhell);
            Car car2 = new Audi("Audi A8", DateTime.Now, CarType.Sedan, DriveType.FrontWhell);

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

            Console.WriteLine("Convert 1st car to String : " + car1.ToString());

            Engine engine  = new Engine(EngineType.diesel, 200, 12);
            Engine eEngine = new Engine(EngineType.electric, 200, 12);

            car1.Engine = engine;
            car2.Engine = engine;

            tesla.Engine = eEngine;

            Console.WriteLine("Move bmw:");
            car1.Move();
            Console.WriteLine("Move audi:");
            car2.Move();
            Console.WriteLine("Move tesla:");
            tesla.Move();

            car1.TurnEngineOff();
            car2.TurnEngineOff();
            tesla.TurnEngineOff();

            Console.WriteLine("{0} vs {1}\n{2} - won!Congratulations!", car1.UniqueID, tesla.UniqueID, ((Car)car1.CompeteWith(tesla)).UniqueID);
        }