Skip to content
Snippets Groups Projects
Commit 9c36681d authored by victorm's avatar victorm
Browse files

Tipos de Contenedores y Contenedor

parent 56c013cc
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ import java.util.List;
* @author victorm
*/
public abstract class Contenedor {
private final List<Trayecto> trayectos = new ArrayList<>();
protected final List<Trayecto> trayectos = new ArrayList<>();
private ISO6346 codigo;
private float pesoTara;
......@@ -117,12 +117,12 @@ public abstract class Contenedor {
* @param costePorMilla El coste por milla recorrida en un trayecto
* @return el precio total del transporte del contenedor
*/
public double precioTransporteTotalContenedor(double costeDiarioTrayecto, double costePorMilla) {
public double precioTransporteTotalContenedor() {
if (this.trayectos.isEmpty())
return 0.0;
double precioTotal = 0.0;
for (Trayecto t : this.trayectos) {
precioTotal += t.precioTrayectoEnEuros(costeDiarioTrayecto, costePorMilla);
precioTotal += t.precioTrayectoEnEuros();
}
return precioTotal;
}
......@@ -138,12 +138,12 @@ public abstract class Contenedor {
* @throws IllegalStateException si la fecha fin del ultimo trayecto es superior a la de inicio del nuevo trayecto
* @throws IllegalStateException si el puerto/muelle destinos del ultimo trayecto no son los de origen del nuevo.
*/
public void anyadirTrayecto(Trayecto t) {
if (t == null)
throw new IllegalArgumentException("El trayecto no puede ser nulo");
if (this.trayectos.isEmpty())
this.trayectos.add(t);
else {
public abstract void anyadirTrayecto(Trayecto t);
protected void comprobarDatosContenedor(Trayecto t) {
Trayecto ultimoT = this.trayectos.get(this.trayectos.size() -1);
//Si la fecha fin es mayor a la de inicio del nuevo
if (ultimoT.getFechaFinTrayecto().getDiasDesdeEpoch() > t.getFechaInicioTrayecto().getDiasDesdeEpoch())
......@@ -156,7 +156,7 @@ public abstract class Contenedor {
throw new IllegalStateException("El Muelle de origen debe de ser igual al de destino de su ultimo trayecto");
this.trayectos.add(t);
}
}
/**
* Metodo que devuelve si un contenedor tiene techo
......
......
......@@ -6,5 +6,19 @@ public class Estandar extends Contenedor {
pesos pesoSeleccionado, volumenes volumenSeleccionado, boolean techo) {
super(codigo, pesoTara, maximaCargaUtil, volumen, estadoActual, pesoSeleccionado, volumenSeleccionado, techo);
}
@Override
public void anyadirTrayecto(Trayecto t) {
if (t==null) {
throw new IllegalArgumentException("h");
}
if (this.trayectos.isEmpty()) {
this.anyadirTrayecto(t);
}
else {
comprobarDatosContenedor(t);
}
}
}
......@@ -5,7 +5,29 @@ public class FlatRack extends Contenedor{
public FlatRack(ISO6346 codigo, float pesoTara, float maximaCargaUtil, float volumen, estados estadoActual,
pesos pesoSeleccionado, volumenes volumenSeleccionado, boolean techo) {
super(codigo, pesoTara, maximaCargaUtil, volumen, estadoActual, pesoSeleccionado, volumenSeleccionado, techo);
// TODO Auto-generated constructor stub
}
@Override
public void anyadirTrayecto(Trayecto t) {
if (t==null) {
throw new IllegalArgumentException("h");
}
if (t instanceof TCamion) {
throw new IllegalArgumentException("No");
}
if (t instanceof TPackCamionBarco) {
throw new IllegalArgumentException("No");
}
if (t instanceof TPackCamionTren) {
throw new IllegalArgumentException("No");
}
comprobarDatosContenedor(t);
}
}
......@@ -5,7 +5,32 @@ public class Refrigerado extends Contenedor{
public Refrigerado(ISO6346 codigo, float pesoTara, float maximaCargaUtil, float volumen, estados estadoActual,
pesos pesoSeleccionado, volumenes volumenSeleccionado, boolean techo) {
super(codigo, pesoTara, maximaCargaUtil, volumen, estadoActual, pesoSeleccionado, volumenSeleccionado, techo);
}
@Override
public void anyadirTrayecto(Trayecto t) {
if (t==null) {
throw new IllegalArgumentException("h");
}
if (t instanceof TTren) {
throw new IllegalArgumentException("No");
}
if (t instanceof TPackCamionBarco) {
throw new IllegalArgumentException("No");
}
if (t instanceof TPackCamionTren) {
throw new IllegalArgumentException("No");
}
comprobarDatosContenedor(t);
}
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ public class ContenedorTest {
@Test
public void testContenedor() {
ISO6346 i1 = new ISO6346("ZRE", 'J', 56731);
Contenedor c1 = new Contenedor(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true);
Contenedor c1 = new Estandar(i1, 100, 400, 500, estados.REGOGIDA, pesos.KILOS, volumenes.METROS, true);
assertEquals("ZREJ0567310", c1.getCodigo());
assertEquals(100.0f, c1.obtenerPesoKilos(), 0.001f);
assertEquals(400.0f, c1.cargaUtilContenedorKilos(), 0.001f);
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment