Example #1
0
        static void Main(string[] args)
        {
            Car      car      = new Car(4, 5, 1200);
            Mercedes mercedes = new Mercedes(4, 5, 4000, 600, "Mercedes-Benz CLS");
            BMW      bMW      = new BMW(4, 5, 3800, 560, "BMW M235i");
            Tesla    tesla    = new Tesla(4, 5, 4000, 650, "Electric Charge", "Tesla S");

            // base class reference variable that points to derived class object
            Car car2 = new Tesla(4, 5, 4000, 650, "Electric Charge", "Tesla S");
            Car car3 = new BMW(4, 5, 3800, 560, "BMW M235i");
            Car car4 = new Mercedes(4, 5, 4000, 600, "Mercedes-Benz CLS");


            car.ShowInfo();
            // dummy engine names
            car.ShowEngine("Mobile Z");
            Console.WriteLine("____________________________________________________________________________");
            bMW.ShowInfo();
            bMW.Model();
            // dummy  engine names
            bMW.ShowEngine("Andrw 5");
            Console.WriteLine("____________________________________________________________________________");
            // dummy engine names
            mercedes.ShowEngine("Say SO");
            mercedes.ShowInfo();
            mercedes.Model();
            Console.WriteLine("____________________________________________________________________________");
            // dummy engine names
            tesla.ShowEngine("TS", 4);
            tesla.ShowEngine("Red R");
            tesla.Model();
            tesla.ShowInfo();
            Console.WriteLine("____________________________________________________________________________");
            // method overriding
            car2.ShowInfo();
            // method overriding
            car3.ShowInfo();
            // method hiding
            car4.ShowInfo();
            Console.WriteLine("____________________________________________________________________________");
            Console.WriteLine("\n");

            // you can't instantiate an object from an abstract class
            //Shape shape = new Shape();  ::: Flag Error

            // base class reference variable that points to derived class object
            Shape shapes = new Rectangle("Rectangle", 10, 8);

            shapes.Area();
            shapes.ShowInfo();

            Console.WriteLine("\n");

            Notify notify = new Notify();

            notify.ShowNotifications();
            Console.WriteLine(notify.GetDate());

            Console.Read();
        }
        static void Main(string[] args)
        {
            Car car1 = new Mercedes("Florin", FuelType.DIESEL, Colour.WHITE);

            ((Mercedes)car1).IsCruiseControlOn = true;
            Console.WriteLine(car1.OwnerName);
            Console.WriteLine(car1.FuelType);
            Console.WriteLine(car1.Colour);
            Console.WriteLine(((Mercedes)car1).IsCruiseControlOn);
            car1.GetSpecialFeature();
            car1.Drive();

            Car car2 = new BMW();

            car2.OwnerName            = "Lucian";
            ((BMW)car2).IsSportModeOn = true;
            Console.WriteLine(car2.OwnerName);
            Console.WriteLine(car2.FuelType);
            Console.WriteLine(car2.Colour);
            Console.WriteLine(((BMW)car2).IsSportModeOn);
            car2.GetSpecialFeature();
            car2.Drive();

            Console.WriteLine(Car.NumberOfCars);

            IShape circle = new Circle();

            circle.Draw();
            IShape square = new Square();

            square.Draw();

            Complex c1 = new Complex(4, 6);
            Complex c2 = new Complex(6, 3);

            Console.WriteLine(c1 + c2);
        }