Update Dados.java

This commit is contained in:
Caio Espindola 2026-06-12 10:44:38 -03:00 committed by GitHub
parent c0b1d78e34
commit 342447e9a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,10 +1,14 @@
public class Dados { public class Dados {
private Aluno[] alunos; private Aluno[] alunos;
private String chamada; private String chamada;
private Acompanhamento[] acompanhamentos;
private Bolsista[] bolsistas;
public Dados(){ public Dados(){
alunos = new Aluno[]{}; alunos = new Aluno[]{};
chamada = ""; chamada = "";
acompanhamentos = new Acompanhamento[]{};
bolsistas = new Bolsista[]{};
} }
public void appendAluno(Aluno aluno){ public void appendAluno(Aluno aluno){
@ -18,6 +22,25 @@ public class Dados {
novoArray[size] = aluno; novoArray[size] = aluno;
this.alunos = novoArray; this.alunos = novoArray;
}
public void appendAcompanhamento(Acompanhamento acomp){
int size = this.acompanhamentos.length;
Acompanhamento[] novoArray = new Acompanhamento[size + 1];
for (int i = 0; i < size; i++){
novoArray[i] = this.acompanhamentos[i];
}
novoArray[size] = acomp;
this.acompanhamentos = novoArray;
}
public void appendBolsista(){
} }
private int findAlunoIndex(String nome){ private int findAlunoIndex(String nome){
@ -28,6 +51,10 @@ public class Dados {
return -1; return -1;
} }
public Aluno findAluno(String nome){
return alunos[findAlunoIndex(nome)];
}
public void listAlunos(){ public void listAlunos(){
for (int i = 0; i < alunos.length; i++){ for (int i = 0; i < alunos.length; i++){
System.out.println(alunos[i].getNome()); System.out.println(alunos[i].getNome());
@ -62,24 +89,28 @@ public class Dados {
} }
public int totalVowels(){ public int totalVowels(){
char[] vowels = new char[]{'a', 'e', 'i', 'o', 'u'};
int sum = 0; int sum = 0;
for (int i = 0; i < vowels.length; i++){ for (int k = 0; k < alunos.length; k++){
for (int k = 0; k < alunos.length; k++){ String nome = alunos[k].getNome();
String nome = alunos[k].getNome(); for (int j = 0; j < nome.length(); j++){
if (isVowel(nome.charAt(j))){
for (int j = 0; j < nome.length(); j++){ sum++;}
if (nome.charAt(j) == vowels[i]){
sum++;}
}
} }
} }
return sum; return sum;
} }
private boolean isVowel(char a){
return (a == 'a') || (a == 'e') || (a == 'i') || (a == 'o') || (a == 'u');
}
public void makeChamada(){ public void makeChamada(){
this.chamada = ""; this.chamada = "";
for (int i = 0; i < alunos.length; i++){ for (int i = 0; i < alunos.length; i++){