//METODOS public override void patrullarCalles(IPatrullable patrullable) { if (vehiculo == null && herramienta == null) { herramienta = new Pistola(); vehiculo = new Patrullero(); } if (patrullable.hayAlgoFueraDeLoNormal()) { vehiculo.getEstado().encender(); vehiculo.encenderSirena(); vehiculo.conducir(); if (vehiculo.getEstado() is Roto) { Console.WriteLine("la patrulla se rompio, el policia no pudo completar su tarea"); } else { this.apagarVehiculo(); this.ordenes[this.numeroOrden].ejecutar(); herramienta.usar(); herramienta.guardar(); } } }
//METODOS public override void atenderInfarto(IInfartable t) { if (rcp is RCP_A) { ((RCP_A)rcp).Contador = 1; } if (vehiculo == null && herramienta == null) { this.vehiculo = new Ambulancia(); this.herramienta = new Desfibrilador(); } vehiculo.encenderSirena(); vehiculo.conducir(); if (this.vehiculo.getEstado() is Roto) { Console.WriteLine("La ambulancia se rompio, el medico no pudo completar su tarea"); } else { this.apagarVehiculo(); herramienta.usar(); Console.WriteLine("Atendiendo infarto"); rcp.realizarRCP(t); herramienta.guardar(); } }
//METODOS public override void revisar(ILuminable lugar) { if (vehiculo == null && herramienta == null) { this.herramienta = new Buscapolo(); this.vehiculo = new Camioneta(); } this.vehiculo.getEstado().encender(); this.vehiculo.encenderSirena(); this.vehiculo.conducir(); if (this.vehiculo.getEstado() is Roto) { Console.WriteLine("La camioneta se rompio, electricista no pudo completar su tarea"); } else { Console.WriteLine("Revisando electricidad"); this.apagarVehiculo(); this.herramienta.usar(); lugar.revisarYCambiarLamparasQuemadas(); this.herramienta.guardar(); } }
public override IResponsable getPersonal() { IVehiculo vehiculo = vehiculos.desencola(); IHerramienta herramienta = herramientas.desencola(); IResponsable responsable = responsables.desencola(); responsable.setVehiculo(vehiculo); responsable.setHerramienta(herramienta); return(responsable); }
public IResponsable getPersonal() { IResponsable responsableListo = responsables[0]; IVehiculo vehiculoListo = vehiculos[0]; IHerramienta herramientaLista = herramientas[0]; responsableListo.setHerramienta(herramientaLista); responsableListo.setVehiculo(vehiculoListo); return(responsableListo); }
public static ICuartel crearHeroe(IFabricaDeHeroes fabricaDeHeroes) { ICuartel cuartel = fabricaDeHeroes.crearCuartel(); IResponsable responsable = fabricaDeHeroes.crearHeroe(); IVehiculo vehiculo = fabricaDeHeroes.crearVehiculo(); IHerramienta herramienta = fabricaDeHeroes.crearHerramienta(); cuartel.agregarVehiculo(vehiculo); cuartel.agregarPersonal(responsable); cuartel.agregarHerramienta(herramienta); return(cuartel); }
public IResponsable getPersonal() { Electricista responsable = (Electricista)this.responsables[contador]; IHerramienta herramienta = this.herramientas[contador]; IVehiculo vehiculo = this.vehiculos[contador]; responsable.setHerramienta(herramienta); responsable.setVehiculo(vehiculo); contador++; return(responsable); }
public override IResponsable getPersonal() { IHerramienta herramienta = herramientas.desencola(); IVehiculo vehiculo = vehiculos.desencola(); IResponsable responsable = responsables.desencola(); Console.WriteLine("Asignando herramienta..."); responsable.setHerramienta(herramienta); Console.WriteLine("Asignando vehiculo..."); responsable.setVehiculo(vehiculo); return(responsable); }
public IResponsable getPersonal() { IHerramienta h = herramientas[0]; herramientas.RemoveAt(0); IVehiculo v = vehiculos[0]; vehiculos.RemoveAt(0); IResponsable r = personal[0]; personal.RemoveAt(0); ((Bombero)r).Herramienta = h; ((Bombero)r).Vehiculo = v; return(r); }
//SOBREESCRIBIENDO EL METODO APAGAR INCENDIO public override void ApagarIncendio2(ILugar pLugar, Calle pCalle) { IResponsable bombero = fabrica.crearHeroe(); IHerramienta manguera = fabrica.crearHerramienta(); IVehiculo autobomba = fabrica.crearVehiculo(); //USO DE PATRON SINGLETON CuartelDeBomberos cuartel = CuartelDeBomberos.getCuartelBombero(); //SE AGREGA AL CUARTEL cuartel.agregarPersonal(bombero); cuartel.agregarHerramienta(manguera); cuartel.agregarVehiculo(autobomba); //OBTENGO EL BOMBERO RESPONSABLE Bombero bomberoResponsable = (Bombero)cuartel.getPersonal(); //LE ASIGNO UNA ESTRATEGIA bomberoResponsable.setEstrategia(new Escalera()); //DELEGO LA TAREA AL VERDADERO BOMBERO, PASANDO EL ILUGAR Y LA CALLE bomberoResponsable.ApagarIncendio2(pLugar, pCalle); }
public override void apagarIncendio(ILugar lugar, Calle calle) { if (vehiculo == null && herramienta == null) { herramienta = new Manguera(); vehiculo = new Autobomba(); } vehiculo.encenderSirena(); vehiculo.conducir(); if (this.vehiculo.getEstado() is Roto) { Console.WriteLine("autobomba se rompio, el policia no pudo completar su tarea"); } else { this.apagarVehiculo(); herramienta.usar(); estrategia.apagarIncendio(lugar, calle.Caudal); herramienta.guardar(); } }
public void setHerramienta(IHerramienta herramienta) { this.Herramienta = herramienta; }
public Policia(ManejadorDeDenuncias m) : base(m) { this.vehiculo = new Patrullero(); this.herramienta = new Pistola(); }
public void setHerramienta(IHerramienta herramienta) { kit = true; this.herramienta = herramienta; }
public void agregarHerramienta(IHerramienta herramienta) { this.herramienta = herramienta; herramientas.Add(herramienta); }
//********************************************************************************************************* //SOBRECARGA DE CONSTRUCTORES public Medico(Manejador manejador, ProtocoloRCP pProtocolo, IHerramienta h, IVehiculo v) : base(manejador) { this.protocolo = pProtocolo; this.herramienta = h; this.vehiculo = v; }
public Bombero(ManejadorDeDenuncias m) : base(m) { this.vehiculo = new Autobomba(); this.herramienta = new Manguera(); }
public override void agregarHerramienta(IHerramienta herramienta) { herramientas.encolar(herramienta); }
public void agregarHerramienta(IHerramienta herramienta) { //herramientas.Add(herramienta); herramientas = herramienta; }
//********************************************************************************************************************* public static void pruebaPatronSingleton() { //CREACION DE FABRICA DE CADA HEROE CON SU VEHICULOS Y HERRAMIENTA FabricaDeBomberos objFabricaBombero = new FabricaDeBomberos(); IResponsable bomberoResponsable = objFabricaBombero.crearHeroe(); IVehiculo vehiculoBombero = objFabricaBombero.crearVehiculo(); IHerramienta herramientaBombero = objFabricaBombero.crearHerramienta(); FabricaDeElectricistas objFabricaElectricista = new FabricaDeElectricistas(); IResponsable electricistaResponsable = objFabricaElectricista.crearHeroe(); IVehiculo vehiculoElectricista = objFabricaElectricista.crearVehiculo(); IHerramienta herramientaElectrica = objFabricaElectricista.crearHerramienta(); FabricaDePolicias objFabricaPolicia = new FabricaDePolicias(); IResponsable policiaResponsable = objFabricaPolicia.crearHeroe(); IVehiculo vehiculoPolicial = objFabricaPolicia.crearVehiculo(); IHerramienta herramientaPolicial = objFabricaPolicia.crearHerramienta(); FabricaDeMedicos objFabricaMedico = new FabricaDeMedicos(); IResponsable medicoResponsable = objFabricaMedico.crearHeroe(); IVehiculo vehiculoMedico = objFabricaMedico.crearVehiculo(); IHerramienta herramientaMedica = objFabricaMedico.crearHerramienta(); //CREACION DE CUARTELES DE LOS HEROES Y SE AGREGA SU PERSONAL RESPONSABLE CORRESPONDIENTE CON SU HERRAMIENTA Y VEHICULO //USO DEL METODO ESTATICO DEL PATRON SINGLETON PARA CREAR UNA SOLA INSTANCIA DEL CUARTEL CuartelDeBomberos cuartelBomberos = CuartelDeBomberos.getCuartelBombero(); cuartelBomberos.agregarPersonal(bomberoResponsable); cuartelBomberos.agregarVehiculo(vehiculoBombero); cuartelBomberos.agregarHerramienta(herramientaBombero); //USO DEL METODO ESTATICO DEL PATRON SINGLETON PARA CREAR UNA SOLA INSTANCIA DEL CUARTEL CentralElectrica central = CentralElectrica.getCuartelElectricista(); central.agregarPersonal(electricistaResponsable); central.agregarVehiculo(vehiculoElectricista); central.agregarHerramienta(herramientaElectrica); //USO DEL METODO ESTATICO DEL PATRON SINGLETON PARA CREAR UNA SOLA INSTANCIA DEL CUARTEL Comisaria cuartelDePolicia = Comisaria.getCuartelPolicia(); cuartelDePolicia.agregarPersonal(policiaResponsable); cuartelDePolicia.agregarVehiculo(vehiculoPolicial); cuartelDePolicia.agregarHerramienta(herramientaPolicial); //USO DEL METODO ESTATICO DEL PATRON SINGLETON PARA CREAR UNA SOLA INSTANCIA DEL CUARTEL Hospital hospital = Hospital.getHospital(); hospital.agregarPersonal(medicoResponsable); hospital.agregarVehiculo(vehiculoMedico); hospital.agregarHerramienta(herramientaMedica); //LE SOLICITAMOS A LOS CUARTES CREADOS, LOS HEROES AGREGADOS ANTERIORMENTE Y PROCEDEMOS A LLAMAR SUS METODOS DE ACCION IResponsable b1 = cuartelBomberos.getPersonal(); Bombero bombero = (Bombero)b1; bombero.setEstrategia(new Escalera()); bombero.ApagarIncendio2(new Plaza(9, new ConstructorSimple()), new Calle(50)); Console.WriteLine(); IResponsable b3 = central.getPersonal(); b3.Revisar(new Plaza()); Console.WriteLine(); IResponsable b2 = cuartelDePolicia.getPersonal(); Policia policia = (Policia)b2; policia.setOrdenPolicial(new OrdenVozdeAlto()); policia.PatrullarCalles(new Plaza()); Console.WriteLine(); IResponsable b4 = hospital.getPersonal(); Medico medico = (Medico)b4; medico.setProtocolo(new ProtocoloA()); medico.AtenderInfarto(new Transeunte()); Console.WriteLine(); }
public void agregarHerramienta(IHerramienta h) { herramientas.Push(h); }
//************************************************************************************************************************* //SOBRECARGA DE CONSTRUCTORES public Bombero(Manejador manejador, IEstrategy estrategia, IHerramienta herramienta, IVehiculo vehiculo) : base(manejador) { this.estrategia = estrategia; this.herramienta = herramienta; this.vehiculo = vehiculo; }
public abstract void agregarHerramienta(IHerramienta herramienta);
public Medico(ManejadorDeDenuncias m) : base(m) { this.vehiculo = new Ambulancia(); this.herramienta = new Desfibrilador(); }
//SOBRECARGA DE CONSTRUCTORES public Policia(Manejador manejador, Iorden pOrden, IHerramienta h, IVehiculo v) : base(manejador) { this.ordenPolicial = pOrden; this.herramienta = h; this.vehiculo = v; }
//SOBRECARGA DE CONSTRUCTORES public Electricista(Manejador manejador, IHerramienta herramienta, IVehiculo vehiculo) : base(manejador) { this.herramienta = herramienta; this.vehiculo = vehiculo; }
//************************************************************************************************************************* //METODOS DE ACCESO public void setHerramienta(IHerramienta pHerramienta) { this.herramienta = pHerramienta; }
//***************************************************************** public void agregarHerramienta(IHerramienta pHerramienta) { this.herramientas.Add(pHerramienta); }
public void agregarHerramienta(IHerramienta h) { herramientas.Add(h); }
public Electricista(ManejadorDeDenuncias m) : base(m) { this.vehiculo = new Camioneta(); this.herramienta = new Buscapolo(); }