diff --git a/src/es/markse/Contenedor.java b/src/es/markse/Contenedor.java index 2ec7eb81fb8ca1991dc4e64f35fdafe846cb16a2..de637547daf6d6bde83ae9265de4852d35ea6c80 100644 --- a/src/es/markse/Contenedor.java +++ b/src/es/markse/Contenedor.java @@ -251,6 +251,5 @@ public class Contenedor { public void anyadirTrayecto(Trayecto t) { //COMPROBAR SI LA FECHA FIN DEL ANTERIOR ES ANTES QUE FECHA INICIO DEL SIGUIENTE //LO MISMO CON EL MUELLE DESTINO Y MUELLE ORIGEN - //LO MISMO PUERTO DESTINO Y PUERTO ORIGEN } } \ No newline at end of file diff --git a/src/es/markse/Fecha.java b/src/es/markse/Fecha.java index de0a953bf2c22bf03bfb0b373e1099ea240ebef6..232c7b031cc6b5d6e104b01443192d872e0abba8 100644 --- a/src/es/markse/Fecha.java +++ b/src/es/markse/Fecha.java @@ -4,10 +4,8 @@ package es.markse; * Implementación de la fecha del calendario gregoriano. * Ejercicio de Programación Orientada a Objetos * Implementación basada en tres atributos - * * @author felix * @author marga - * */ public class Fecha { diff --git a/src/es/markse/Muelle.java b/src/es/markse/Muelle.java index 5d88b4ed01b10f83d4baf7afb96346c16fd365de..5c07ba8cf2e50796e9dc221a45244435c9fa34da 100644 --- a/src/es/markse/Muelle.java +++ b/src/es/markse/Muelle.java @@ -456,6 +456,5 @@ public class Muelle { plazasLlenas++; } } - } - + } } \ No newline at end of file diff --git a/src/es/markse/Puerto.java b/src/es/markse/Puerto.java index 833837916d6208629cde3f2094d185ccc85bcc3e..24ac1a709410a5dbe0ebc66657076bf02947ed9c 100644 --- a/src/es/markse/Puerto.java +++ b/src/es/markse/Puerto.java @@ -170,4 +170,4 @@ public class Puerto { public String ciudadDelPuerto() { return this.ciudad; } -} +} \ No newline at end of file diff --git a/src/es/markse/Trayecto.java b/src/es/markse/Trayecto.java index 77047b6139db3a484f6aa6a7d8e30ecd31d93ca3..b93de1e6e588eb0d980e0a943f84cf6f527e942e 100644 --- a/src/es/markse/Trayecto.java +++ b/src/es/markse/Trayecto.java @@ -3,7 +3,6 @@ */ package es.markse; - /** * Implementacion de la clase Trayecto * @author vicmtorm @@ -19,7 +18,7 @@ public class Trayecto { private Fecha fechaFinTrayecto; /** * Constructor del objeto Trayecto. - * @param muelleOrigen Muelle desde el que se empieza el Trayecto + * @param muelleOrigen Muelle desde el que se e mpieza el Trayecto * @param puertoOrigen Puerto desde el que se empieza el Trayecto * @param fechaInicioTrayecto Fecha en la que comienza el Trayecto * @param muelleDestino Muelle en el que finaliza un Trayecto @@ -27,15 +26,18 @@ public class Trayecto { * @param fechaFinTrayecto Fecha en la que finaliza un Trayecto */ public Trayecto (Muelle muelleOrigen, Puerto puertoOrigen, Fecha fechaInicioTrayecto, Muelle muelleDestino, Puerto puertoDestino, Fecha fechaFinTrayecto) { + comprobacionMuellesDistintos(muelleOrigen, muelleDestino); + comprobacionPuertosDistintos(puertoOrigen, puertoDestino); + comprobacionFecha(fechaInicioTrayecto); + comprobacionFecha(fechaFinTrayecto); + comprobacionOrdenFechas(fechaInicioTrayecto,fechaFinTrayecto); this.muelleOrigen=muelleOrigen; this.puertoOrigen=puertoOrigen; this.fechaInicioTrayecto=fechaInicioTrayecto; this.muelleDestino = muelleDestino; this.puertoDestino = puertoDestino; this.fechaFinTrayecto = fechaFinTrayecto; - comprobacionFecha(fechaInicioTrayecto); - comprobacionFecha(fechaFinTrayecto); - comprobacionOrdenFechas(); + } public Muelle getMuelleOrigen() { @@ -57,9 +59,38 @@ public class Trayecto { return this.fechaFinTrayecto; } + + /** + * Método que Comprueba si los Muelles Introducidos son Distintos o no + * @param muelleOrigen Muelle desde el que comienza el Trayecto + * @param muelleDestino Muelle en el que finaliza el Trayecto + * @throws IllegalArgumentException Si el Muelle de Origen y el Muelle de Destino son el Mismo + */ + + + private void comprobacionMuellesDistintos(Muelle muelleOrigen, Muelle muelleDestino) { + if (muelleOrigen.getIdentificador()==muelleDestino.getIdentificador()) { + throw new IllegalArgumentException ("¡El Muelle de Origen no puede ser igual al Muelle de Destino!"); + } + } + + /** + * Método que Comprueba si los Puertos Introducidos son Distintos o no, fijándonos en la Localidad + * @param puertoOrigen Puerto desde el que comienza el Trayecto + * @param puertoDestino Puerto en el que finaliza el Trayecto + * @throws IllegalArgumentException Si el Puerto de Origen y el Puerto de Destino son el Mismo + */ + + private void comprobacionPuertosDistintos(Puerto puertoOrigen, Puerto puertoDestino) { + if (puertoOrigen.ciudadDelPuerto()==puertoDestino.ciudadDelPuerto()) { + throw new IllegalArgumentException ("¡El Puerto de Origen no puede ser igual al Puerto de Destino!"); + } + } + /** * Método que Comprueba si la Fecha Introducida al Declarar un nuevo Trayecto es válida o no * @param fechaDada Fecha Introducida por el Usuario + * @throws IllegalArgumentException Si la Fecha a Comprobar es Nula, o no es una fecha válida */ private void comprobacionFecha(Fecha fechaDada) { @@ -77,11 +108,12 @@ public class Trayecto { /** * Método que Comprueba si el Orden de las Fechas de Inicio y del Final del Trayecto es el adecuado. + * @throws IllegalArgumentException Si la Fecha del Inicio del Trayecto es Posterior a la Fecha del Fin del Trayecto, lo cual es Imposible. */ - private void comprobacionOrdenFechas() { - if (this.fechaInicioTrayecto.getDiasDesdeEpoch()>this.fechaFinTrayecto.getDiasDesdeEpoch()){ + private void comprobacionOrdenFechas(Fecha fechaInicioTrayecto, Fecha fechaFinTrayecto) { + if (fechaInicioTrayecto.getDiasDesdeEpoch()>fechaFinTrayecto.getDiasDesdeEpoch()){ throw new IllegalArgumentException ("La Fecha del Inicio del Trayecto no puede ser posterior a la fecha del Fin del Trayecto"); } } @@ -152,3 +184,4 @@ public class Trayecto { "\nINFORMACION SOBRE EL DESTINO: \nCiudad Destino: "+ciudadDest+"\nPais Destino: "+paisDest+"\nFecha del Fin: "+FechaFin; } } + diff --git a/uses/es/markse/ContenedorTest.java b/uses/es/markse/ContenedorTest.java index 2dd26f7135ef71310687353c3568cacc1e741efd..000a1fba48b6da70a805fc45b1520632c4fd01cf 100644 --- a/uses/es/markse/ContenedorTest.java +++ b/uses/es/markse/ContenedorTest.java @@ -5,7 +5,6 @@ package es.markse; import static org.junit.Assert.*; import org.junit.Test; - import es.uva.inf.poo.maps.GPSCoordinate; /** diff --git a/uses/es/markse/MuelleTest.java b/uses/es/markse/MuelleTest.java index 700c2ad2b1c72dc316d580a9cab67411e7473bd2..c37fb104ae1478126ec6d17bcf1980fdb881b718 100644 --- a/uses/es/markse/MuelleTest.java +++ b/uses/es/markse/MuelleTest.java @@ -1,6 +1,7 @@ /** * Copyrigth Universidad de Valladolid 2024/2025 */ + package es.markse; import static org.junit.Assert.*; import org.junit.Test; diff --git a/uses/es/markse/PuertoTest.java b/uses/es/markse/PuertoTest.java index f2f0c482730b0cc07f10d697a495504adca60c21..79bdd4df7e505a3a07fc5de963f226ab1d2d3530 100644 --- a/uses/es/markse/PuertoTest.java +++ b/uses/es/markse/PuertoTest.java @@ -7,6 +7,7 @@ import org.junit.Test; import es.uva.inf.poo.maps.GPSCoordinate; + /** * Test realizados para la clase Puerto * @author javcalv diff --git a/uses/es/markse/TrayectoTest.java b/uses/es/markse/TrayectoTest.java index 9d9305a3dc4b6bb38ca58dfd8c90aaf7ffe3dee5..da350056d3afe77e903296773515150b8abb2ba5 100644 --- a/uses/es/markse/TrayectoTest.java +++ b/uses/es/markse/TrayectoTest.java @@ -13,7 +13,7 @@ public class TrayectoTest { Muelle m1 = new Muelle ("01",c1,true,2,2); Muelle m2 = new Muelle ("02",c2,true,2,2); Puerto p1 = new Puerto ("ES","BAR"); - Puerto p2 = new Puerto ("ES","BAR"); + Puerto p2 = new Puerto ("AR","BUE"); Fecha f1 = new Fecha (9,11,2024); Fecha f2 = new Fecha(11,11,2024); Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2); @@ -107,25 +107,95 @@ public class TrayectoTest { Fecha f2 = new Fecha(11,11,2024); Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2); assertEquals(f2,t.getFechaFinTrayecto()); + } + + @Test(expected = IllegalArgumentException.class) + public void testcomprobacionMuellesDistintos() { + GPSCoordinate c1 = new GPSCoordinate(5d,5d); + GPSCoordinate c2 = new GPSCoordinate(10d,10d); + Muelle m1 = new Muelle ("01",c1,true,2,2); + Muelle m2 = new Muelle ("01",c2,false,4,1); + Puerto p1 = new Puerto ("ES","PAL"); + Puerto p2 = new Puerto ("AR","BUE"); + Fecha f1 = new Fecha (9,11,2024); + Fecha f2 = new Fecha(11,11,2024); + Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2); + } - - @Test - public void comprobacionFecha() { + @Test(expected = IllegalArgumentException.class) + public void testcomprobacionPuertosDistintos() { + GPSCoordinate c1 = new GPSCoordinate(5d,5d); + GPSCoordinate c2 = new GPSCoordinate(10d,10d); + Muelle m1 = new Muelle ("01",c1,true,2,2); + Muelle m2 = new Muelle ("02",c2,false,2,2); + Puerto p1 = new Puerto ("ES","PAL"); + Puerto p2 = new Puerto ("ES","PAL"); + Fecha f1 = new Fecha (9,11,2024); + Fecha f2 = new Fecha(11,11,2024); + Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2); + } - @Test - public void testPrecioTrayectoEnEuros() { - fail("Not yet implemented"); - } + @Test(expected = IllegalArgumentException.class) + public void testcomprobacionFecha() { + GPSCoordinate c1 = new GPSCoordinate(5d,5d); + GPSCoordinate c2 = new GPSCoordinate(10d,10d); + Muelle m1 = new Muelle ("01",c1,true,2,2); + Muelle m2 = new Muelle ("02",c2,false,2,2); + Puerto p1 = new Puerto ("ES","PAL"); + Puerto p2 = new Puerto ("ES","VAL"); + Fecha f1 = new Fecha (9,11,2024); + Fecha f2 = new Fecha(5,11,2024); + Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2); +} + + + @Test(expected = IllegalArgumentException.class) + public void testcomprobacionFechaNula() { + GPSCoordinate c1 = new GPSCoordinate(5d,5d); + GPSCoordinate c2 = new GPSCoordinate(10d,10d); + Muelle m1 = new Muelle ("01",c1,true,2,2); + Muelle m2 = new Muelle ("02",c2,false,2,2); + Puerto p1 = new Puerto ("ES","PAL"); + Puerto p2 = new Puerto ("ES","VAL"); + Fecha f1 = new Fecha (9,11,2024); + Fecha f2 = null; + Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2); - @Test - public void testDistanciaMillasMarinas() { - fail("Not yet implemented"); } + + @Test(expected = IllegalArgumentException.class) + public void testcomprobacionFechaImposible() { + GPSCoordinate c1 = new GPSCoordinate(5d,5d); + GPSCoordinate c2 = new GPSCoordinate(10d,10d); + Muelle m1 = new Muelle ("01",c1,true,2,2); + Muelle m2 = new Muelle ("02",c2,false,2,2); + Puerto p1 = new Puerto ("ES","PAL"); + Puerto p2 = new Puerto ("ES","VAL"); + Fecha f1 = new Fecha (0,11,1999); + Fecha f2 = new Fecha (30,12,2000); + Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2); - @Test - public void testInforTrayecto() { - fail("Not yet implemented"); } -} \ No newline at end of file +} + //@Test + //public void comprobacionFecha() { + //} + + //@Test + //public void testPrecioTrayectoEnEuros() { + //fail("Not yet implemented"); + //} + + //@Test + //public void testDistanciaMillasMarinas() { + //fail("Not yet implemented"); + //} + + //@Test + //public void testInforTrayecto() { + //fail("Not yet implemented"); + //} + +//}