-
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
8ba9bd7
commit 122db8b
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
01-lecture/quemepongo/src/main/java/quemepongo/model/usuario/guardarropa/Guardarropa.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,48 @@ | ||
package quemepongo.model.usuario.guardarropa; | ||
|
||
import java.util.HashMap; | ||
import java.util.LinkedHashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import quemepongo.model.prenda.Categoria; | ||
import quemepongo.model.prenda.Prenda; | ||
|
||
/** | ||
* Guardarropa, repositorio de Prendas. | ||
* | ||
* @since 05.27.2021 | ||
* @version 1.0 | ||
*/ | ||
public class Guardarropa { | ||
|
||
/** | ||
* Prendas categorizadas. | ||
* | ||
* @since Iteración V | ||
*/ | ||
Map<Categoria, Set<Prenda>> prendas = new HashMap<Categoria, Set<Prenda>>(); | ||
|
||
public Guardarropa() { | ||
|
||
Categoria[] categorias = Categoria.values(); | ||
|
||
for (Categoria categoria : categorias) { | ||
prendas.put(categoria, new LinkedHashSet<Prenda>()); | ||
} | ||
} | ||
|
||
/** | ||
* Agrega una prenda al guardarropas. | ||
* | ||
* @param prenda la prenda a añadir | ||
* @return el guardarropa | ||
* @since Iteración V | ||
*/ | ||
public Guardarropa agregarPrenda(Prenda prenda) { | ||
|
||
Set<Prenda> prendasDeCategoria = prendas.get(prenda.categoria()); | ||
prendasDeCategoria.add(prenda); | ||
|
||
return this; | ||
} | ||
} |