Beispiel #1
0
        static void Main(string[] args)
        {
            // 公共汽车在市区街道上面行驶
            IVehicle l_bus  = new Bus();
            IRoad    l_road = new StreetWay();

            l_road.VehicleName = l_bus;
            l_road.Run();

            // 公共汽车在高速公路上面行驶
            IRoad l_speedWay = new SpeedWay();

            l_speedWay.VehicleName = l_bus;
            l_speedWay.Run();
            Console.ReadKey();
        }
Beispiel #2
0
        public override void Test(Action<Task[]> callBack)
        {
            AbstractPeple man = new Man();
            AbstractPeple woMan = new WoMan();
            AbstractCar car = new Car();
            AbstractCar bus = new Bus();
            AbstractRoad speedWay = new SpeedWay();
            AbstractRoad street = new Street();

            speedWay.Car = car;
            speedWay.Run();
            speedWay.Car = bus;
            speedWay.Run();

            street.Car = car;
            street.Run();
            street.Car = bus;
            street.Run();

            car.Peple = man;
            speedWay.Car = car;
            street.Car = car;
            speedWay.Run();
            street.Run();

            car.Peple = woMan;
            speedWay.Car = car;
            street.Car = car;
            speedWay.Run();
            street.Run();

            bus.Peple = man;
            speedWay.Car = bus;
            street.Car = bus;
            speedWay.Run();
            street.Run();

            bus.Peple = woMan;
            speedWay.Car = bus;
            street.Car = bus;
            speedWay.Run();
            street.Run();

            callBack.Invoke(null);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            //解决中文问题
            Console.OutputEncoding = Encoding.UTF8;
            //小汽车在高速公路上行驶;
            AbstractRoad Road1 = new SpeedWay();

            Road1.Car = new Car();
            Road1.Run();
            Console.WriteLine("=========================");

            //公共汽车在高速公路上行驶;
            AbstractRoad Road2 = new Street();

            Road2.Car = new Bus();
            Road2.Run();
            Console.Read();
        }