Exemple #1
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);
        }