static void AbstractFactory() { var copFactory = new CopFactory(); var quarter = CreateHeroe(copFactory); var personal = (Cop)quarter.GetPersonal(); personal.PatrolStreet(new House(100, 25, 4)); quarter.AddResponsable(personal); quarter.AddTool(personal.Tool); quarter.AddVehicle(personal.Vehicle); var fireFactory = new FireFighterFactory(); quarter = CreateHeroe(fireFactory); var personal2 = (Firefighter)quarter.GetPersonal(); personal2.PutOutFire(new House(100, 25, 4), new Street(25, 4, 10)); quarter.AddResponsable(personal2); quarter.AddTool(personal2.Tool); quarter.AddVehicle(personal2.Vehicle); var electriciaFactory = new ElectricianFactory(); quarter = CreateHeroe(electriciaFactory); var personal3 = (Electrician)quarter.GetPersonal(); personal3.changeBurntLamps(new Street(25, 4, 10)); quarter.AddResponsable(personal3); quarter.AddTool(personal3.Tool); quarter.AddVehicle(personal3.Vehicle); }
public Electrician CreateHeroe(CompliantHandler handler = null) { if (_electricianFactory == null) { _electricianFactory = new ElectricianFactory(); } var eletrician = (Electrician)_electricianFactory.CreateHeroe(handler); eletrician.Tool = _electricianFactory.CreateTool(); eletrician.Vehicle = _electricianFactory.CreateVehicle(); return(eletrician); }