Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

vceniceros
Copy link

No description provided.

@vceniceros
Copy link
Author

propuesta de solucion

Comment on lines +10 to +12
private ArrayList<Vehiculo> vehiculos = new ArrayList<Vehiculo>();
private ArrayList<Cliente> clientes = new ArrayList<Cliente>();
private ArrayList<Inmueble> inmuebles = new ArrayList<Inmueble>();

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?)

Comment on lines +14 to +30
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);
}

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

Comment on lines +52 to +68
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();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

También acá

Comment on lines +70 to +77
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();
}
Copy link

@laldonate96 laldonate96 Oct 1, 2024

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.

Copy link

@laldonate96 laldonate96 left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants