Skip to content

Commit 7de226c

Browse files
committed
Atualiza projeto
1 parent fbdbdaf commit 7de226c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

estatisticas-estudantes-estruturado/src/main/java/AppProgramacaoEstruturada.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public AppProgramacaoEstruturada(){
1414
estudantes = StudentGenerator.generate(TOTAL_STUDENTS);
1515

1616
imprimeMaiorNota();
17+
imprimeMaiorNotaHomens();
1718
imprimeMaiorHomens();
1819
imprimeTotalHomens();
1920
imprimeTotalMulheres();
@@ -159,6 +160,16 @@ private void imprimeMaiorNota() {
159160
System.out.printf("Maior nota entre todos os Estudantes: %.2f\n", maiorNota);
160161
}
161162

163+
private void imprimeMaiorNotaHomens() {
164+
double maiorNota = 0;
165+
for (Estudante estudante : estudantes) {
166+
if (estudante.getSexo() == 'M' && estudante.getNota() > maiorNota) {
167+
maiorNota = estudante.getNota();
168+
}
169+
}
170+
System.out.printf("Maior nota eentre Homens: %.2f\n", maiorNota);
171+
}
172+
162173
private void imprimeMaiorHomens() {
163174
double maiorNota = 0;
164175
for (Estudante estudante : estudantes) {

estatisticas-estudantes-funcional/src/main/java/AppProgramacaoFuncional.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ private void imprimeMaiorNota() {
4747
private void imprimeMaiorNotaHomens() {
4848
final double maior =
4949
estudantes.stream()
50-
.filter(Estudante::isHomem)
51-
.mapToDouble(Estudante::getNota)
50+
.filter((Estudante e) -> e.getSexo() == 'M')
51+
.mapToDouble((Estudante e) -> e.getNota())
5252
.max()
5353
.orElse(0);
5454
System.out.printf("Maior nota entre todos os Estudantes: %.2f\n", maior);

0 commit comments

Comments
 (0)