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
vinicius
committed
Jan 13, 2021
1 parent
636ed21
commit 85b451a
Showing
3 changed files
with
69 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,93 @@ | ||
import java.util.ArrayList; | ||
|
||
public class Album { | ||
|
||
public static final int PERCENTUAL_MINIMO_PARA_AUTO_COMPLETAR = 90; // 90% | ||
|
||
private Figurinha[] figurinhasColadas; | ||
|
||
private int contRepetidas[]; | ||
|
||
private int totalFigurinhasColadas; | ||
|
||
private int totalFigurinhasRepetidas; | ||
|
||
private int quantFigurinhasPorPacotinho; | ||
|
||
private int tamanhoDoAlbum; | ||
|
||
public Album(int tamanhoDoAlbum, int quantFigurinhasPorPacotinho) { | ||
// ToDo IMPLEMENT ME!!!! | ||
figurinhasColadas = new Figurinha[tamanhoDoAlbum + 1]; | ||
contRepetidas = new int[tamanhoDoAlbum + 1]; | ||
this.quantFigurinhasPorPacotinho = quantFigurinhasPorPacotinho; | ||
this.tamanhoDoAlbum = tamanhoDoAlbum; | ||
} | ||
|
||
public void receberNovoPacotinho(Pacotinho pacotinho) { | ||
for (Figurinha fig : pacotinho) { | ||
|
||
|
||
// ToDo IMPLEMENT ME!! | ||
int posicao = fig.getPosicao(); | ||
if (figurinhasColadas[posicao] == null) { | ||
// figurinha inédita! | ||
colarFigurinhaInedita(fig); | ||
} else { | ||
// figurinha repetida! | ||
contRepetidas[posicao]++; | ||
totalFigurinhasRepetidas++; | ||
} | ||
} | ||
} | ||
|
||
private void colarFigurinhaInedita(Figurinha fig) { | ||
figurinhasColadas[fig.getPosicao()] = fig; | ||
totalFigurinhasColadas++; | ||
} | ||
|
||
|
||
public void autoCompletar() { | ||
// verifica se o álbum já está suficientemente cheio | ||
if (this.totalFigurinhasColadas >= | ||
this.tamanhoDoAlbum * PERCENTUAL_MINIMO_PARA_AUTO_COMPLETAR / 100f) { | ||
for (int i = 1; i <= this.tamanhoDoAlbum; i++) { | ||
if (this.figurinhasColadas[i] == null) { | ||
Figurinha fig = new Figurinha(i); | ||
colarFigurinhaInedita(fig); | ||
} | ||
} | ||
} | ||
|
||
// ToDo IMPLEMENT ME!! | ||
} | ||
|
||
public int getTamanho() { | ||
// ToDo IMPLEMENT ME!!! | ||
return 0; | ||
return this.tamanhoDoAlbum; | ||
} | ||
|
||
public int getQuantFigurinhasPorPacotinho() { | ||
// ToDo IMPLEMENT ME!!! | ||
return 0; | ||
return this.quantFigurinhasPorPacotinho; | ||
} | ||
|
||
public int getQuantFigurinhasColadas() { | ||
// ToDo IMPLEMENT ME!!! | ||
return 0; | ||
return this.totalFigurinhasColadas; | ||
} | ||
|
||
public int getQuantFigurinhasRepetidas() { | ||
// ToDo IMPLEMENT ME!!! | ||
return 0; | ||
return this.totalFigurinhasRepetidas; | ||
} | ||
|
||
public boolean possuiFigurinhaColada(int posicao) { | ||
// ToDo IMPLEMENT ME!!! | ||
return false; | ||
if (posicao < 1 || posicao > this.tamanhoDoAlbum) { | ||
return false; | ||
} | ||
return this.figurinhasColadas[posicao] != null; | ||
} | ||
|
||
public boolean possuiFigurinhaRepetida(int posicao) { | ||
// ToDo IMPLEMENT ME!!! | ||
return false; | ||
if (posicao < 1 || posicao > this.tamanhoDoAlbum) { | ||
return false; | ||
} | ||
return this.contRepetidas[posicao] > 0; | ||
} | ||
|
||
public int getQuantFigurinhasFaltantes() { | ||
// ToDo IMPLEMENT ME!!! | ||
return 0; | ||
return this.tamanhoDoAlbum - this.totalFigurinhasColadas; | ||
} | ||
} |
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,13 +1,15 @@ | ||
public class Figurinha { | ||
|
||
public Figurinha(int posicao) { | ||
private int posicao; | ||
|
||
public Figurinha(int posicao) { | ||
this.posicao = posicao; | ||
} | ||
|
||
/** | ||
* @return A posição que esta figurinha deve ocupar no álbum | ||
*/ | ||
public int getPosicao() { | ||
return 0; // ToDo IMPLEMENT ME!!!! | ||
return this.posicao; | ||
} | ||
} |
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