public static Car BuyACar() { CarEngine selectedEngine = new CarEngine(); //Select an Engine you like CarWheel selectedWheel = new CarWheel(); //Select a Wheel you like Car car = CarVendingMachine.GetACarFromFactory(selectedEngine, selectedWheel); return(car); }
public static Car BuyACar() { CarEngine selectedEngine = new CarEngine(); //Select an Engine you like CarWheel selectedWheel = new CarWheel(); //Select a Wheel you like // Only Caller has the knowledge of Engine & Wheel Func <CarGas, Car> getARunningCarWithGas = gas => CarFactory.BuildARunningCar(selectedEngine, selectedWheel, gas); Car car = CarVendingMachine.GetACarFromFactory(getARunningCarWithGas); return(car); }