-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implemento mi solucion #4
base: master
Are you sure you want to change the base?
Conversation
propuesta de solucion |
private ArrayList<Vehiculo> vehiculos = new ArrayList<Vehiculo>(); | ||
private ArrayList<Cliente> clientes = new ArrayList<Cliente>(); | ||
private ArrayList<Inmueble> inmuebles = new ArrayList<Inmueble>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
La idea de la implementación de la interfaz Alquilable
es justamente abstraer esto para no tener multiples listas con distintos tipos de Alquilables (imaginate que tenes 10 tipos de Alquilables distintos, tendrías 10 listas?)
public void registrarVehiculo(Vehiculo unVehiculo) { | ||
for(Vehiculo vehiculo: vehiculos){ | ||
if(vehiculo.esIgualA(unVehiculo)){ | ||
throw new VehiculoYaRegistradoException(); | ||
} | ||
} | ||
vehiculos.add(unVehiculo); | ||
} | ||
|
||
void registrarInmueble(Inmueble unInmueble) { | ||
for(Inmueble inmueble: inmuebles){ | ||
if(inmueble.esIgualA(unInmueble)){ | ||
throw new InmuebleYaRegistradoException(); | ||
} | ||
} | ||
inmuebles.add(unInmueble); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lo mismo acá, si tenés muchos alquilables? Serían muchos métodos para lo mismo
private Vehiculo buscarVehiculo(Vehiculo unVehiculo) { | ||
for(Vehiculo vehiculo: vehiculos){ | ||
if(vehiculo.esIgualA(unVehiculo)){ | ||
return vehiculo; | ||
} | ||
} | ||
throw new VehiculoNoRegistradoException(); | ||
} | ||
|
||
private Inmueble buscarInmueble(Inmueble unInmueble){ | ||
for(Inmueble inmueble: inmuebles){ | ||
if(inmueble.esIgualA(unInmueble)){ | ||
return inmueble; | ||
} | ||
} | ||
throw new VehiculoNoRegistradoException(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
También acá
private Alquilable buscarAlquilable(Alquilable unAlquilable) { | ||
if (unAlquilable instanceof Vehiculo) { | ||
return buscarVehiculo((Vehiculo) unAlquilable); | ||
} else if (unAlquilable instanceof Inmueble) { | ||
return buscarInmueble((Inmueble) unAlquilable); | ||
} | ||
throw new AlquilableNoRegistradoException(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acá primero que nada instanceof
está rompiendo tell dont ask, y la idea es usar polimorfismo con la abstrancción que te permite la implementación del alquilable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
La idea está bien, con las correcciones debería salir completo. El resto está bien, los tests y las excepciones.
No description provided.