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
Showing
4 changed files
with
55 additions
and
40 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Repositorio { | ||
public class Repositorio<T extends Colecionavel> { | ||
|
||
private static final String PREFIXO_URL_IMAGENS = "http://www.nossoalbum.com.br/imagens/"; | ||
|
||
private List<Colecionavel> todasAsFigurinhas; | ||
private List<T> todosOsItens; | ||
|
||
private int quantFigurinhas; | ||
|
||
@SuppressWarnings("unchecked") | ||
public Repositorio(String sufixoUrlImagens, int quantFigurinhas, String tipoDeColecionavel) { | ||
this.quantFigurinhas = quantFigurinhas; | ||
public Repositorio(String sufixoUrlImagens, int quantItens, String tipoDeColecionavel) { | ||
this.quantFigurinhas = quantItens; | ||
|
||
todasAsFigurinhas = new ArrayList<>(); | ||
todasAsFigurinhas.add(null); // ocupando a posição 0 com um null | ||
for (int i = 1; i <= quantFigurinhas; i++) { | ||
todosOsItens = new ArrayList<>(); | ||
todosOsItens.add(null); // ocupando a posição 0 com um null | ||
for (int i = 1; i <= quantItens; i++) { | ||
|
||
Colecionavel item = ColecionavelFactory.criarColecionavel( | ||
T item = (T) ColecionavelFactory.criarColecionavel( | ||
tipoDeColecionavel, i, PREFIXO_URL_IMAGENS + sufixoUrlImagens); | ||
todasAsFigurinhas.add(item); | ||
todosOsItens.add(item); | ||
} | ||
} | ||
|
||
public int getTotalFigurinhas() { | ||
return this.quantFigurinhas; | ||
} | ||
|
||
public Colecionavel getItem(int pos) { | ||
return this.todasAsFigurinhas.get(pos); | ||
public T getItem(int pos) { | ||
return this.todosOsItens.get(pos); | ||
} | ||
} |