// Solution B: Let object creator supply objects of // correct type, which are then passed on to // EnvironmentGeneratorBase constructor. // This will also work, if you later decide to create // classes inheriting from the original ...Future classes. public EnvironmentGeneratorFuture( BuildingFactoryFuture bf, CreatureFactoryFuture cf, WeaponFactoryFuture wf) : base(bf, cf, wf) { }
private static void RunExisting() { Console.WriteLine("Test of EnvironmentGeneratorBase (flawed...)"); IBuildingFactory bf = new BuildingFactoryFuture(); ICreatureFactory cf = new CreatureFactoryMedieval(); IWeaponFactory wf = new WeaponFactoryFuture(); IEnvironmentGenerator generator = new EnvironmentGeneratorBase(bf, cf, wf); Generate(generator, 2, 3, 4); Console.WriteLine(); }