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;
}
}
}
@@ -0,0 +1,16 @@
package es.madrid.redmetro.rmr.service;
import es.madrid.redmetro.rmr.dao.ILinea;
import es.madrid.redmetro.rmr.dao.impl.LineaJDBC;
import es.madrid.redmetro.rmr.exception.RedMetroException;
import es.madrid.redmetro.rmr.model.Linea;
public class LineaService {
private ILinea lineaDAO = new LineaJDBC();
public Linea obtenerLineaConColor (int codigoLinea) throws RedMetroException {
return lineaDAO.obtenerLineaPorCodigo(codigoLinea);
}
}
@@ -0,0 +1,22 @@
package es.madrid.redmetro.rmr.service;
import java.util.List;
import es.madrid.redmetro.rmr.dao.ITren;
import es.madrid.redmetro.rmr.dao.impl.TrenJDBC;
import es.madrid.redmetro.rmr.exception.RedMetroException;
import es.madrid.redmetro.rmr.model.Tren;
public class TrenService {
private ITren trenDAO = new TrenJDBC();
public void insertarTren (Tren tren) throws RedMetroException {
trenDAO.insertarTren(tren);
}
public List<Tren> obtenerTodosLosTrenes() throws RedMetroException {
return trenDAO.obtenerTodosLosTrenes();
}
}