Esempio n. 1
0
        public static void Main(string[] args)
        {
            Person person = new Person
            {
                FirstName   = "Abc",
                LastName    = "Xyz",
                DateOfBirth = new DateTime(1992, 11, 16)
            };

            Console.WriteLine("Age is {0}", person.GetAge());


            //Static Polymorphism
            DieselEngine dieselEngine = new DieselEngine();

            dieselEngine.Start();

            //Dynamic Polymorphism
            Engine engine = new PetrolEngine();

            engine.Start();

            Exhaustable exhaustable = new Car(engine);

            exhaustable.Exhaust();

            exhaustable = new PowerGenerator();
            exhaustable.Exhaust();
        }
Esempio n. 2
0
    public static void Main()
    {
        Car    ciaz   = new Car();
        Engine engine = new DieselEngine();

        Console.WriteLine(engine.Start());
        Console.WriteLine(engine.engineType());
        Console.WriteLine(ciaz.Start());
        Console.WriteLine(ciaz.Accelerate());
        Console.WriteLine(engine.Stop());
        Console.WriteLine(ciaz.Stop());
    }