Пример #1
0
 public void AddEngine(mycar car)
 {
     if (car is toyota)
     {
         toyota toyotaCar = (toyota)car;
         toyotaCar.Engine = "Дизельний двигун";
         Console.WriteLine("Diesel  додав двигун до авто : " + car);
     }
 }
Пример #2
0
        static void Main_2(string[] args)
        {
            mycar toyotaCar1 = new toyota();

            toyotaCar1.ManufactureCar();
            Console.WriteLine(toyotaCar1 + "\n");
            Diesel carWithDieselEngine = new Diesel(toyotaCar1);

            carWithDieselEngine.ManufactureCar();
            Console.WriteLine();
            mycar  toyotaCar2          = new toyota();
            Petrol carWithPetrolEngine = new Petrol(toyotaCar2);

            carWithPetrolEngine.ManufactureCar();
            Console.ReadKey();
        }