static void Main(string[] args) { ICarFactory fordCar = new FordCarFactory(); ICarFactory bmwCar = new BMWCarFactory(); CarWorld carWorld = new CarWorld(bmwCar); //fordCar yerine bmwCar yaz ve dene. carWorld.CarInfos(); Console.Read(); }
static void Main(string[] args) { ICarFactory carFactory; // 生产宝马 carFactory = new BMWCarFactory(); carFactory.CreateCar(); // 生产别克 carFactory = new BuickCarFactory(); carFactory.CreateCar(); // 生产大众 carFactory = new VolkswagenCarFactory(); carFactory.CreateCar(); }