示例#1
0
        static void Main(string[] args)
        {
            ICarFactory carFactory = new ToyotaFactory();

            Car myCar = carFactory.CreateCar();

            myCar.Info();
            Engine myEngine = carFactory.CreateEngine();

            myEngine.GetPower();
            Wheels myWheels = carFactory.CreateWheels();

            myWheels.GetDiametr();

            carFactory = new FordFactory();
            myCar      = carFactory.CreateCar();
            myCar.Info();
            myEngine = carFactory.CreateEngine();
            myEngine.GetPower();
            myWheels = carFactory.CreateWheels();
            myWheels.GetDiametr();

            carFactory = new MersedesFactory();
            myCar      = carFactory.CreateCar();
            myCar.Info();
            myEngine = carFactory.CreateEngine();
            myEngine.GetPower();
            myWheels = carFactory.CreateWheels();
            myWheels.GetDiametr();

            Console.ReadKey();
        }
示例#2
0
        static void Main(string[] args)
        {
            ICarFactory carFactory = new ToyotaFactory();
            Car         myCar      = carFactory.CreateCar();

            myCar.Info();
            Engine myEngine = carFactory.CreateEngine();

            myEngine.GetPower();
            carFactory = new FordFactory();
            myCar      = carFactory.CreateCar();
            myCar.Info();
            myEngine = carFactory.CreateEngine();
            myEngine.GetPower();
            Console.ReadKey();
        }