示例#1
0
        static void Main(string[] args)
        {
            Vehicle[] vehicles = new Vehicle[3];
            vehicles[0] = new Car("Car", DateTime.Now.AddDays(95));
            vehicles[1] = new Plane("Plane", DateTime.Now.AddDays(40));
            vehicles[2] = new Boat("Boat", DateTime.Now.AddDays(100));

            foreach (var v in vehicles)
            {
                v.Start();
                v.Idle();
                v.Stop();
            }

            foreach (IGarage v in vehicles)
            {
                MaintainVehicle(v);

                if (v is Car)
                {
                    Car car = v as Car;
                    car.TestBrakes();
                }
                if (v is Plane)
                {
                    Plane plane = v as Plane;
                    plane.TestBrakes();
                }

                if (v is Boat)
                {
                    Boat boat = v as Boat;
                    boat.TestHydroDisplacement();
                }
            }

            WriteLine("Complete........................");
            ReadKey();
        }