Example #1
0
        static void Main(string[] args)
        {
            //base can call any function of deriving class
            Car Bmw = new BMW(800, "290i", "grey", "BMW");

            Bmw.showDetails();
            Bmw.showDetailz();

            //Create a list of cars
            var cars = new List <Car>
            {
                new BMW(2000, "Yellow", "320i", "BMW"),
                new Audi(700, "Green", "RS7", "Audi")
            };

            //loop through list to get showdetails() of each object
            foreach (var ride in cars)
            {
                //ride.showDetails();
            }


            Car Benz = new Car(300, "Purple");

            //Benz.CarDetails();



            BMW benz = new BMW(450, "Blue", "C63", "Merc");

            //benz.CarDetails();


            //to show content of base class on deriving member
            Car carb = (Car)benz;

            carb.CarDetails();


            //######## - SEALED - ######
            //Rs7_subclassAudi_.cs

            Rs7_subclassAudi_ Rs7 = new Rs7_subclassAudi_(890, "Indigo", "RS77", "S-Line");

            Rs7.showNews();


            //Has A Relationship

            //Works on oly new classes created here
            Bmw.SetCarID(32, "Mr. Amponsah");


            Bmw.GetCarIDinfo();


            Console.ReadKey();
        }
Example #2
0
        static void Main(string[] args)
        {
            var cars = new System.Collections.Generic.List <Car>
            {
                new Audi(200, "Blue", "A4"),
                new BMW(250, "Grey", "320")
            };


            foreach (var car in cars)
            {
                car.showDetails();
                car.repair();
            }


            Car BMWZ3 = new BMW(200, "black", "z3");

            BMWZ3.showDetails();
            BMWZ3.SetCarIdInfo(1234, "Me");


            BMWZ3.GetCaridInfo();
        }