Esempio n. 1
0
        static void Main(string[] args)
        {
            var myBike = new Zero();

            //I can still reference the inherited class
            myBike.MainColor    = "Black";
            myBike.MaxOccupancy = 2;
            myBike.Name         = "Zero";

            var myTesla = new Tesla();

            myTesla.MainColor    = "Midnight Silver";
            myTesla.MaxOccupancy = 6;
            myTesla.Name         = "Tesla";

            var myRam = new Ram();

            myRam.MainColor    = "blue";
            myRam.Name         = "Ram";
            myRam.MaxOccupancy = 5;

            var myCessna = new Cessna();

            myCessna.MainColor    = "green";
            myCessna.Name         = "Cessna";
            myCessna.MaxOccupancy = 10;

            myBike.Drive();
            myTesla.Drive();
            myCessna.Drive();
            myRam.Drive();

            myBike.Turn("taking a left");
            myBike.Stop();

            myTesla.Turn("taking a right");
            myTesla.Stop();

            myRam.Turn("taking several wrong turns");
            myRam.Stop();

            myCessna.Turn("doing loops!");
            myCessna.Stop();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var myBike = new Zero();

            // I can still reference the inherited property
            myBike.MainColor    = "Black";
            myBike.MaxOccupancy = 2;

            var myTesla = new Tesla();

            myTesla.MainColor    = "Midnight Silver";
            myTesla.MaxOccupancy = 6;

            var myRam = new Ram();

            myRam.MainColor = "Black as midnight on a moonless night";

            var myCessna = new Cessna();

            myCessna.MainColor = "Drug runner White";

            myBike.Drive();
            myBike.Turn();
            myBike.Stop();

            myTesla.Drive();
            myTesla.Turn();
            myTesla.Stop();

            myRam.Drive();
            myRam.Turn();
            myRam.Stop();

            myCessna.Drive();
            myCessna.Turn();
            myCessna.Stop();

            Console.WriteLine(myTesla);

            double price = 15.50;

            Console.WriteLine(price.ToString("C"));
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var myBike = new Zero();

            // I can still refer to the inherited property
            myBike.MainColor     = "Black";
            myBike.MaxOccupancey = 2;

            var myTesla = new Tesla();

            myTesla.MainColor     = "Midnight Silver";
            myTesla.MaxOccupancey = 6;

            var myRam = new Ram();

            myRam.MainColor     = "Candy Apple Red";
            myRam.MaxOccupancey = 5;

            var myCessna = new Cessna();

            myCessna.MainColor     = "Olive Green";
            myCessna.MaxOccupancey = 4;

            myBike.Drive();
            myBike.Turn();
            myBike.Stop();
            myTesla.Drive();
            myTesla.Turn();
            myTesla.Stop();
            myRam.Drive();
            myRam.Turn();
            myRam.Stop();
            myCessna.Drive();
            myCessna.Turn();
            myCessna.Stop();
        }