SIMULACRO EXAMEN - Red Metro

This commit is contained in:
rocio.montero1
2026-11-07 13:14:22 +01:00
commit 9865dbd9c5
28 changed files with 1201 additions and 0 deletions
@@ -0,0 +1,41 @@
package es.madrid.redmetro.rmr.service;
import es.madrid.redmetro.rmr.dao.ICochera;
import es.madrid.redmetro.rmr.dao.impl.CocheraJDBC;
import es.madrid.redmetro.rmr.exception.RedMetroException;
import es.madrid.redmetro.rmr.model.Cochera;
public class CocheraService {
private ICochera cocheraDAO = new CocheraJDBC();
public void procesarOperacion(int codigoOperacion, Cochera cochera) throws RedMetroException {
switch (codigoOperacion) {
case 1:
Cochera cocheraEnBD = cocheraDAO.obtenerCocheraPorCodigo(codigoOperacion);
if (cocheraEnBD == null) {
cocheraDAO.insertarCochera(cochera);
System.out.println("Cochera " + cochera.getCodigoCochera()+ " insertada correctamente.");
} else {
System.out.println("Cochera " + cochera.getCodigoCochera() + " ya existe.");
}
break;
case 2:
cocheraDAO.actualizarCochera(cochera);
System.out.println("Cochera " + cochera.getCodigoCochera() + " actualizada.");
break;
case 3:
cocheraDAO.borrarCochera(cochera.getCodigoCochera());
System.out.println("Cochera " + cochera.getCodigoCochera() + " borrada.");
break;
default: // default es 0
break;
}
}
}