-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7016d1d
commit 78ac0d8
Showing
4 changed files
with
136 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...mepongo/src/main/java/quemepongo/service/prenda/guardarropa/SugerenciasDeGuardarropa.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package quemepongo.service.prenda.guardarropa; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import quemepongo.model.atuendo.Atuendo; | ||
import quemepongo.model.atuendo.Conjunto; | ||
import quemepongo.model.clima.Clima; | ||
import quemepongo.model.clima.CondicionClimatica; | ||
import quemepongo.model.prenda.Categoria; | ||
import quemepongo.model.prenda.Prenda; | ||
import quemepongo.service.clima.ServicioMetereologico; | ||
|
||
/** | ||
* Sugerencias de Atuendos | ||
*/ | ||
public class SugerenciasDeGuardarropa { | ||
|
||
/** | ||
* Prendas categorizadas. | ||
* | ||
* @since Iteración VI | ||
*/ | ||
private Map<Categoria, Set<Prenda>> prendas; | ||
|
||
/** | ||
* Prendas categorizadas. | ||
* | ||
* @since Iteración IV | ||
*/ | ||
private ServicioMetereologico pronostico = ServicioMetereologico.defaultService(); | ||
|
||
private CondicionClimatica condicionesClimaticas; | ||
|
||
public SugerenciasDeGuardarropa(Map<Categoria, Set<Prenda>> prendas, | ||
ServicioMetereologico pronostico) { | ||
this.prendas = prendas; | ||
this.pronostico = pronostico; | ||
setCondicionClimatica(); | ||
} | ||
|
||
public Atuendo sugerirAtuendo() { | ||
return new Atuendo(sugerirConjuntoSegunClima()); | ||
} | ||
|
||
private Conjunto sugerirConjuntoSegunClima() { | ||
Clima clima = condicionesClimaticas.getClima(); | ||
return new Conjunto(sugerirPrenda(Categoria.SUPERIOR, clima), | ||
sugerirPrenda(Categoria.INFERIOR, clima), sugerirPrenda(Categoria.CALZADO, clima), | ||
sugerirPrenda(Categoria.ACCESORIOS, clima)); | ||
} | ||
|
||
private SugerenciasDeGuardarropa setCondicionClimatica() { | ||
this.condicionesClimaticas = pronostico.getCondicionClimatica("Buenos Aires"); | ||
return this; | ||
} | ||
|
||
/** | ||
* Busca una Prenda segun el clima. | ||
* | ||
* @param categoria la categoria de la prenda a buscar | ||
* @return una prenda apta para el clima | ||
*/ | ||
private Prenda sugerirPrenda(Categoria categoria, Clima clima) { | ||
|
||
Set<Prenda> prendasDeCategoria = prendas.get(categoria); | ||
Optional<Prenda> prenda = | ||
prendasDeCategoria.stream().filter(p -> p.getTipo().aptoClima(clima)).findAny(); | ||
|
||
return prenda.isPresent() ? prenda.get() : null; | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
01-lecture/quemepongo/src/test/java/quemepongo/service/clima/ServicioMetereologicoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package quemepongo.service.clima; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class ServicioMetereologicoTest { | ||
|
||
@Test | ||
void testGetCondicionClimatica() { | ||
|
||
} | ||
} |