Example #1
0
        public static void Run()
        {
            Car c1 = new Car()
            {
                Passengers = 2
            };
            Car c2 = new Car()
            {
                Passengers = 3
            };

            Taxi t1 = new Taxi();

            Bus b1 = new Bus();

            DeliveryTruck d1 = new DeliveryTruck();

            Console.WriteLine($"CalculateTollByType ({c1.GetType()}): " + CalculateTollByType(c1));
            Console.WriteLine($"CalculateTollByType ({b1.GetType()}): " + CalculateTollByType(b1));
            Console.WriteLine($"CalculateTollByType ({d1.GetType()}): " + CalculateTollByType(d1));

            Console.WriteLine($"CalculateTollByProperty ({c1.GetType()}): " + CalculateTollByProperty(c1));
            Console.WriteLine($"CalculateTollByProperty ({c2.GetType()}): " + CalculateTollByProperty(c2));
            Console.WriteLine($"CalculateTollByProperty ({b1.GetType()}): " + CalculateTollByProperty(b1));
            Console.WriteLine($"CalculateTollByProperty ({d1.GetType()}): " + CalculateTollByProperty(d1));
        }