Esempio n. 1
0
        static void Main(string[] args)
        {
            var buick = new Buick("DEF54321");

            buick.Drive();
            buick.Stop();
            buick.EngageHandicapHanger();
            RecordLicensePlate(buick);
            GetMyRange(buick);
            Console.WriteLine(buick.Plate);
            Console.WriteLine("---------------");

            Vehicle vehicle             = buick;
            TransportationDevice device = buick;
            var range = device.Range;
            // this won't work - CreatingThisAsAnExample(vehicle);

            var lambo = new Lambo("ABC1234");

            lambo.Drive();
            lambo.Stop();
            RecordLicensePlate(lambo);
            GetMyRange(lambo);
            Console.WriteLine(lambo.Plate);
            Console.WriteLine("---------------");

            Vehicle imposter = new SomeLamboImposter("asdfasdf");

            imposter.Drive(); // SomeLamboImposter.Drive() will be called
            Console.WriteLine("---------------");

            Console.ReadLine();
        }
Esempio n. 2
0
 public static void GetMyRange(TransportationDevice device)
 {
     Console.WriteLine($"Your range is {device.Range}");
 }