From fc5c0a84f9b83859d9b2402cc5f386a862889aff Mon Sep 17 00:00:00 2001
From: Javier Calvo <javiercalvoporro@gmail.com>
Date: Sun, 10 Nov 2024 20:10:43 +0100
Subject: [PATCH] Puerto al 99%%

---
 src/es/markse/Contenedor.java      |   1 -
 src/es/markse/Fecha.java           |   1 -
 src/es/markse/Muelle.java          |   1 -
 src/es/markse/Puerto.java          |   1 -
 src/es/markse/Trayecto.java        | 116 +++++++++++--------
 uses/es/markse/ContenedorTest.java |   3 +-
 uses/es/markse/MuelleTest.java     |   3 +-
 uses/es/markse/PuertoTest.java     |   1 +
 uses/es/markse/TrayectoTest.java   | 171 +++++++++++++++++++++--------
 9 files changed, 205 insertions(+), 93 deletions(-)

diff --git a/src/es/markse/Contenedor.java b/src/es/markse/Contenedor.java
index 1c24410..44673c8 100644
--- a/src/es/markse/Contenedor.java
+++ b/src/es/markse/Contenedor.java
@@ -70,7 +70,6 @@ public class Contenedor {
         }
 	}
 	
-	
 	/**
 	 * metodo para comparar si el numero de serie es correcto
 	 * @param numeroSerie el numero de serie del contenedor
diff --git a/src/es/markse/Fecha.java b/src/es/markse/Fecha.java
index 232c7b0..2c9f741 100644
--- a/src/es/markse/Fecha.java
+++ b/src/es/markse/Fecha.java
@@ -8,7 +8,6 @@ package es.markse;
  * @author marga
  */
 public class Fecha {
-	
 	private int anno;
 	private int mes;
 	private int dia;
diff --git a/src/es/markse/Muelle.java b/src/es/markse/Muelle.java
index 5c07ba8..74ed1c3 100644
--- a/src/es/markse/Muelle.java
+++ b/src/es/markse/Muelle.java
@@ -14,7 +14,6 @@ import es.uva.inf.poo.maps.GPSCoordinate;
  * @author victorm
  */
 public class Muelle {
-	
 	private Plaza[] plazas;
 	private String identificador;
 	private boolean operativo;
diff --git a/src/es/markse/Puerto.java b/src/es/markse/Puerto.java
index 319742c..957deba 100644
--- a/src/es/markse/Puerto.java
+++ b/src/es/markse/Puerto.java
@@ -19,7 +19,6 @@ public class Puerto {
 	private String pais;
 	private String ciudad;
 	private List<Muelle> muelles = new ArrayList<>();
-
 	/**
 	 * Constructor del objeto Puerto.
 	 * @param pais Pais al que pertenece el puerto (2 letras)
diff --git a/src/es/markse/Trayecto.java b/src/es/markse/Trayecto.java
index b93de1e..76a8764 100644
--- a/src/es/markse/Trayecto.java
+++ b/src/es/markse/Trayecto.java
@@ -7,7 +7,6 @@ package es.markse;
  * Implementacion de la clase Trayecto
  * @author vicmtorm
  * @author javcalv
- *
  */
 public class Trayecto {
 	private Muelle muelleOrigen;
@@ -26,8 +25,11 @@ 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);
+		disponibilidadMuelle(muelleOrigen);
+		disponibilidadMuelle(muelleDestino);
+		muellePerteneceAlPuerto(muelleOrigen,puertoOrigen);
+		muellePerteneceAlPuerto(muelleDestino,puertoDestino);
+		comprobacionMuellesDistintos(muelleOrigen, muelleDestino, puertoOrigen, puertoDestino);
 		comprobacionFecha(fechaInicioTrayecto);
 		comprobacionFecha(fechaFinTrayecto);
 		comprobacionOrdenFechas(fechaInicioTrayecto,fechaFinTrayecto);
@@ -36,74 +38,107 @@ public class Trayecto {
 		this.fechaInicioTrayecto=fechaInicioTrayecto;
 		this.muelleDestino = muelleDestino;
 		this.puertoDestino = puertoDestino;
-		this.fechaFinTrayecto = fechaFinTrayecto;
-		
+		this.fechaFinTrayecto = fechaFinTrayecto;	
 	}
+	
+	/**
+	 * Método que Devuelve el Muelle de Origen
+	 * @return muelleOrigen
+	 */
 
 	public Muelle getMuelleOrigen() {
 		return this.muelleOrigen;
 	}
+	
+	/**
+	 * Método que Devuelve el Muelle de Destino
+	 * @return muelleDestino
+	 */
+	
 	public Muelle getMuelleDestino() {
 		return this.muelleDestino;
 	}
+	
+	/**
+	 * Método que Devuelve el Puerto de Origen
+	 * @return puertoOrigen
+	 */
+	
 	public Puerto getPuertoOrigen() {
 		return this.puertoOrigen;
 	}
+	
+	/**
+	 * Método que Devuelve el Puerto de Destino
+	 * @return puertoDestino
+	 */
+	
 	public Puerto getPuertoDestino() {
 		return this.puertoDestino;
 	}
+	
+	/**
+	 * Método que Devuelve la Fecha del Inicio del Trayecto
+	 * @return fechaInicioTrayecto
+	 */
+	
 	public Fecha getFechaInicioTrayecto() {
 		return this.fechaInicioTrayecto;
 	}
+	
+	/**
+	 * Método que Devuelve la Fecha del Fin del Trayecto
+	 * @return fechaFinTrayecto
+	 */
+	
 	public Fecha getFechaFinTrayecto() {
 		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
+	 * Método que comprueba si un Muelle está Operativo o está Fuera de Servicio
+	 * @param muelle Muelle para el que queremos conocer su disponibilidad
+	 * @throws Illegal Argument Exception En el caso de que el Muelle se encuentre Fuera de Servicio
 	 */
 	
+	private void disponibilidadMuelle(Muelle muelle) {
+		if (!muelle.estaOperativo()) throw new IllegalArgumentException ("¡El Muelle Introducido está Fuera de Servicio!");
+	}
 	
-	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 un Muelle Introducido pertenece al Puerto Introducido
+	 * @param muelle Tipo Muelle
+	 * @param puerto Tipo Puerto
+	 * @throws Illegal Argument Exception En el caso de que el Muelle no se encuentre en ese Puerto
+	 */
+	
+	private void muellePerteneceAlPuerto(Muelle muelle, Puerto puerto) {
+		if (!puerto.comprobarMuelleEnPuerto(muelle))throw new IllegalArgumentException ("¡El Muelle Introducido no Pertenece al Puerto Introducido!");
 	}
 	
 	/**
-	 * 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
+	 * 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 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!");
+	private void comprobacionMuellesDistintos(Muelle muelleOrigen, Muelle muelleDestino, Puerto puertoOrigen, Puerto puertoDestino) {
+		if (muelleOrigen.getIdentificador()== muelleDestino.getIdentificador()&& puertoOrigen.identificadorPuerto().equals(puertoDestino.identificadorPuerto())) {
+			throw new IllegalArgumentException ("¡El Muelle de Origen no puede ser igual al Muelle 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
+	 * @throws IllegalArgumentException Si la Fecha a Comprobar es Nula
 	 */
 	
 	private void comprobacionFecha(Fecha fechaDada) {
 		if (fechaDada == null) {
 			throw new IllegalArgumentException ("La Fecha introducida no puede ser nula");
 		}
-		int d = fechaDada.getDia();
-		int m = fechaDada.getMes();
-		int a = fechaDada.getAnno();
-		
-		if((d>fechaDada.diasMes(m,a))|| (d<1) || (m<1) || (m>12) || (a<1000) || (a>9999)) {
-			throw new IllegalArgumentException ("La Fecha Introducida no es Válida");
-		}
 	}
 	
 	/**
@@ -111,7 +146,6 @@ public class Trayecto {
 	 * @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(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");
@@ -124,15 +158,13 @@ public class Trayecto {
 	 * @return True si la Fecha de Fin de Trayecto es Superior, y False si la Fecha de Fin de Trayecto no es Superior
 	 */
 	
-	
 	public boolean FechaFinTrayectoSuperior(Fecha fechaDada) {
+		if (fechaDada == null) throw new IllegalArgumentException("Fecha no puede ser nula");
 		if (fechaFinTrayecto.getDiasDesdeEpoch()>fechaDada.getDiasDesdeEpoch()) {
-			System.out.println("La Fecha del Fin del Trayecto es superior a la Fecha Dada");
-			return true;
+			return false;
 		}
 		else {
-			System.out.println("La Fecha del Fin del Trayecto NO es superior a la Fecha Dada");
-			return false;
+			return true;
 		}
 	
 	}
@@ -148,25 +180,24 @@ public class Trayecto {
 		if (costeDiarioTrayecto <= 0) {
 			throw new IllegalArgumentException ("El Coste Diario del Trayecto no es válido");
 		}
-		if (costePorMilla <= 0) {
+		else if(costePorMilla <= 0) {
 			throw new IllegalArgumentException ("El Coste por Milla del Trayecto no es válido");
 		}
-		int dias = fechaFinTrayecto.getDiasDesdeEpoch()-fechaInicioTrayecto.getDiasDesdeEpoch();
+		int dias = (fechaFinTrayecto.getDiasDesdeEpoch()-fechaInicioTrayecto.getDiasDesdeEpoch())+1;
 		double dist = distanciaMillasMarinas();
 		return ((dias*costeDiarioTrayecto)+(dist*costePorMilla));
 	}
 	
-	
 	/**
 	 * Método que devuelve la Distancia calculada en Millas Marinas entre 2 Muelles Distintos
 	 * @return Distancia entre 2 Muelles Distintos calculada en Millas Marinas
 	 * 
 	 */
+	
 	public double distanciaMillasMarinas() {
 		return muelleOrigen.getGPSCoordinate().getDistanceTo(muelleDestino.getGPSCoordinate());
 	}
 
-	
 	/**
 	 * Método que Proporciona Información acerca del Trayecto: Localidad y País de los Puertos de Origen y Destino, y Fechas de Inicio y Fin del Trayecto
 	 * @return Información Sobre el Origen (Ciudad, Pais, Fecha Inicio) y el Destino (Ciudad, Pais, Fecha Fin)
@@ -180,8 +211,7 @@ public class Trayecto {
 		String paisDest = this.puertoDestino.paisDelPuerto();
 		String FechaFin = this.fechaFinTrayecto.aCadena();
 		
-		return"INFORMACION SOBRE EL ORIGEN: \nCiudad Origen: "+ciudadOrig+"\nPais Origen: "+paisOrig+"\nFecha del Inicio: "+FechaInicio+
-				"\nINFORMACION SOBRE EL DESTINO: \nCiudad Destino: "+ciudadDest+"\nPais Destino: "+paisDest+"\nFecha del Fin: "+FechaFin;
+		return"INFORMACION SOBRE EL ORIGEN: \nCiudad Origen: "+ciudadOrig+"\nPais Origen: "+paisOrig+"\nInicio del Trayecto: "+FechaInicio+
+				"\n\nINFORMACION SOBRE EL DESTINO: \nCiudad Destino: "+ciudadDest+"\nPais Destino: "+paisDest+"\nFin del Trayecto: "+FechaFin+"\n";
 	}
-}
-
+}
\ No newline at end of file
diff --git a/uses/es/markse/ContenedorTest.java b/uses/es/markse/ContenedorTest.java
index d49196d..9ab4121 100644
--- a/uses/es/markse/ContenedorTest.java
+++ b/uses/es/markse/ContenedorTest.java
@@ -13,7 +13,7 @@ import es.uva.inf.poo.maps.GPSCoordinate;
  * @author javcalv
  */
 public class ContenedorTest {
-
+	
 	@Test
 	public void testContenedor() {
 		Contenedor c = new Contenedor("RTF", 'Z', "065432", 100, 400, 1000, false, true);
@@ -244,4 +244,5 @@ public class ContenedorTest {
 		Trayecto t2 = new Trayecto(m3,destino,fFin,mNuevo,destino,fFin2);
 		c.anyadirTrayecto(t2);
 	}
+	
 }
\ No newline at end of file
diff --git a/uses/es/markse/MuelleTest.java b/uses/es/markse/MuelleTest.java
index c37fb10..d8ef274 100644
--- a/uses/es/markse/MuelleTest.java
+++ b/uses/es/markse/MuelleTest.java
@@ -390,4 +390,5 @@ public class MuelleTest {
 		assertEquals(1, m.plazasSemillenas());
 		m.sacarContenedorDePlaza(c4);
 	}
-}
+	
+}
\ No newline at end of file
diff --git a/uses/es/markse/PuertoTest.java b/uses/es/markse/PuertoTest.java
index 79bdd4d..b0785db 100644
--- a/uses/es/markse/PuertoTest.java
+++ b/uses/es/markse/PuertoTest.java
@@ -191,4 +191,5 @@ public class PuertoTest {
 		Puerto p = new Puerto("ES","BAR");
 		p.muellesCercanoAPunto(null);
 	}
+	
 }
\ No newline at end of file
diff --git a/uses/es/markse/TrayectoTest.java b/uses/es/markse/TrayectoTest.java
index da35005..a21c952 100644
--- a/uses/es/markse/TrayectoTest.java
+++ b/uses/es/markse/TrayectoTest.java
@@ -9,11 +9,13 @@ public class TrayectoTest {
 	@Test
 	public void testTrayecto() {
 		GPSCoordinate c1 = new GPSCoordinate(5d,5d);
-		GPSCoordinate c2 = new GPSCoordinate(10d,10d);
+		GPSCoordinate c2 = new GPSCoordinate(5d,5d);
 		Muelle m1 = new Muelle ("01",c1,true,2,2);
-		Muelle m2 = new Muelle ("02",c2,true,2,2);
+		Muelle m2 = new Muelle ("01",c1,true,2,2);
 		Puerto p1 = new Puerto ("ES","BAR");
 		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
 		Fecha f1 = new Fecha (9,11,2024);
 		Fecha f2 = new Fecha(11,11,2024);
 		Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
@@ -24,6 +26,49 @@ public class TrayectoTest {
 		assertEquals(p2,t.getPuertoDestino());
 		assertEquals(f2,t.getFechaFinTrayecto());
 	}
+	
+	@Test(expected = IllegalArgumentException.class)
+	public void testTrayectoFechaNull() {
+		GPSCoordinate c1 = new GPSCoordinate(5d,5d);
+		GPSCoordinate c2 = new GPSCoordinate(5d,5d);
+		Muelle m1 = new Muelle ("01",c1,true,2,2);
+		Muelle m2 = new Muelle ("01",c1,true,2,2);
+		Puerto p1 = new Puerto ("ES","BAR");
+		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
+		Fecha f2 = new Fecha(11,11,2024);
+		new Trayecto(m1,p1,null,m2,p2,f2);
+	}
+	
+	@Test(expected = IllegalArgumentException.class)
+	public void testTrayectoMuelleNoPertenecePuerto() {
+		GPSCoordinate c1 = new GPSCoordinate(5d,5d);
+		GPSCoordinate c2 = new GPSCoordinate(5d,5d);
+		Muelle m1 = new Muelle ("01",c1,true,2,2);
+		Muelle m2 = new Muelle ("01",c1,true,2,2);
+		Puerto p1 = new Puerto ("ES","BAR");
+		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		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(expected = IllegalArgumentException.class)
+	public void testTrayectoFechaInicioPosteriorAFin() {
+		GPSCoordinate c1 = new GPSCoordinate(5d,5d);
+		GPSCoordinate c2 = new GPSCoordinate(5d,5d);
+		Muelle m1 = new Muelle ("01",c1,true,2,2);
+		Muelle m2 = new Muelle ("01",c1,true,2,2);
+		Puerto p1 = new Puerto ("ES","BAR");
+		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
+		Fecha f1 = new Fecha (9,11,2024);
+		Fecha f2 = new Fecha(11,11,2024);
+		Trayecto t = new Trayecto(m1,p1,f2,m2,p2,f1);
+	}
 
 	@Test
 	public void testGetMuelleOrigen() {
@@ -33,6 +78,8 @@ public class TrayectoTest {
 		Muelle m2 = new Muelle ("02",c2,true,2,2);
 		Puerto p1 = new Puerto ("ES","PAL");
 		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
 		Fecha f1 = new Fecha (9,11,2024);
 		Fecha f2 = new Fecha(11,11,2024);
 		Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
@@ -47,6 +94,8 @@ public class TrayectoTest {
 		Muelle m2 = new Muelle ("02",c2,true,2,2);
 		Puerto p1 = new Puerto ("ES","PAL");
 		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
 		Fecha f1 = new Fecha (9,11,2024);
 		Fecha f2 = new Fecha(11,11,2024);
 		Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
@@ -61,6 +110,8 @@ public class TrayectoTest {
 		Muelle m2 = new Muelle ("02",c2,true,2,2);
 		Puerto p1 = new Puerto ("ES","PAL");
 		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
 		Fecha f1 = new Fecha (9,11,2024);
 		Fecha f2 = new Fecha(11,11,2024);
 		Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
@@ -75,6 +126,8 @@ public class TrayectoTest {
 		Muelle m2 = new Muelle ("02",c2,true,2,2);
 		Puerto p1 = new Puerto ("ES","PAL");
 		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
 		Fecha f1 = new Fecha (9,11,2024);
 		Fecha f2 = new Fecha(11,11,2024);
 		Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
@@ -89,6 +142,8 @@ public class TrayectoTest {
 		Muelle m2 = new Muelle ("02",c2,true,2,2);
 		Puerto p1 = new Puerto ("ES","PAL");
 		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
 		Fecha f1 = new Fecha (9,11,2024);
 		Fecha f2 = new Fecha(11,11,2024);
 		Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
@@ -103,6 +158,8 @@ public class TrayectoTest {
 		Muelle m2 = new Muelle ("02",c2,true,2,2);
 		Puerto p1 = new Puerto ("ES","PAL");
 		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
 		Fecha f1 = new Fecha (9,11,2024);
 		Fecha f2 = new Fecha(11,11,2024);
 		Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
@@ -114,28 +171,18 @@ public class TrayectoTest {
 		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(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);
+		Muelle m2 = new Muelle ("01",c1,true,2,2);
 		Puerto p1 = new Puerto ("ES","PAL");
 		Puerto p2 = new Puerto ("ES","PAL");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
 		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(expected = IllegalArgumentException.class)
 	public void testcomprobacionFecha() {
 		GPSCoordinate c1 = new GPSCoordinate(5d,5d);
@@ -144,6 +191,8 @@ public class TrayectoTest {
 		Muelle m2 = new Muelle ("02",c2,false,2,2);
 		Puerto p1 = new Puerto ("ES","PAL");
 		Puerto p2 = new Puerto ("ES","VAL");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
 		Fecha f1 = new Fecha (9,11,2024);
 		Fecha f2 = new Fecha(5,11,2024);
 		Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
@@ -158,44 +207,78 @@ public class TrayectoTest {
 		Muelle m2 = new Muelle ("02",c2,false,2,2);
 		Puerto p1 = new Puerto ("ES","PAL");
 		Puerto p2 = new Puerto ("ES","VAL");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
 		Fecha f1 = new Fecha (9,11,2024);
 		Fecha f2 = null;
-		Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
-
+		new Trayecto(m1,p1,f1,m2,p2,f2);
 	}
-	
+
+
 	@Test(expected = IllegalArgumentException.class)
-	public void testcomprobacionFechaImposible() {
+	public void testPrecioTrayectoEnEuros() {
 		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);
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
+		Fecha f1 = new Fecha (1,11,1999);
 		Fecha f2 = new Fecha (30,12,2000);
+		Trayecto t = new Trayecto (m1,p1,f1,m2,p2,f2);
+		t.precioTrayectoEnEuros(2,0);
+	}
+	
+	@Test
+	public void testFechaFinTrayectoSuperior() {
+		GPSCoordinate c1 = new GPSCoordinate(5d,5d);
+		GPSCoordinate c2 = new GPSCoordinate(5d,5d);
+		Muelle m1 = new Muelle ("01",c1,true,2,2);
+		Muelle m2 = new Muelle ("01",c1,true,2,2);
+		Puerto p1 = new Puerto ("ES","BAR");
+		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
+		Fecha f1 = new Fecha (9,11,2024);
+		Fecha f2 = new Fecha(11,11,2024);
 		Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
-
+		assertFalse(t.FechaFinTrayectoSuperior(f1));
+		Fecha f3 = new Fecha(13,11,2024);
+		assertTrue(t.FechaFinTrayectoSuperior(f3));
 	}
-
-}
-	//@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");
-	//}
-
-//}
+	
+	@Test(expected = IllegalArgumentException.class)
+	public void testFechaFinTrayectoSuperiorNula() {
+		GPSCoordinate c1 = new GPSCoordinate(5d,5d);
+		GPSCoordinate c2 = new GPSCoordinate(5d,5d);
+		Muelle m1 = new Muelle ("01",c1,true,2,2);
+		Muelle m2 = new Muelle ("01",c1,true,2,2);
+		Puerto p1 = new Puerto ("ES","BAR");
+		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
+		Fecha f1 = new Fecha (9,11,2024);
+		Fecha f2 = new Fecha(11,11,2024);
+		Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
+		t.FechaFinTrayectoSuperior(null);
+	}
+	
+	@Test
+	public void testDistanciaMillasMarinas() {
+		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,true,2,2);
+		Puerto p1 = new Puerto ("ES","BAR");
+		Puerto p2 = new Puerto ("AR","BUE");
+		p1.anyadirMuelle(m1);
+		p2.anyadirMuelle(m2);
+		Fecha f1 = new Fecha (9,11,2024);
+		Fecha f2 = new Fecha(11,11,2024);
+		Trayecto t = new Trayecto(m1,p1,f1,m2,p2,f2);
+		double v = 781.1062793857914;
+		assertEquals(v, t.distanciaMillasMarinas(), 0.001);
+	}
+}
\ No newline at end of file
-- 
GitLab