-1
Good morning Friends, I am having a lot of difficulties in making this application work, I am not able to calculate the days of absence of the students, my difficulty is in the class Agenda in the method marcarFalta(int getMatricula, int mes, int dia)because I have to get the student’s license plate and the day of the absence in that month. Thanks in advance.
package Gerenciar_frequencia;
public class Principal {
public static void main(String[] args) {
Turma turma = new Turma("Est. de dados","A1","20191");
turma.inserirAluno(new Aluno("Anselmo",111));
turma.inserirAluno(new Aluno("Pedro",222));
turma.inserirAluno(new Aluno("Joao",333));
turma.imprimir();
System.out.println("------------------------------------------");
Pauta pauta = new Pauta(3,6,turma);
pauta.marcarFalta(111, 3, 5);
pauta.marcarFalta(111, 3, 12);
pauta.marcarFalta(111, 3, 21);
pauta.marcarFalta(111, 3, 26);
pauta.marcarFalta(111, 4, 2);
pauta.marcarFalta(111, 4, 4);
pauta.marcarFalta(111, 4, 11);
pauta.marcarFalta(111, 4, 23);
pauta.marcarFalta(111, 4, 25);
pauta.marcarFalta(111, 4, 30);
pauta.marcarFalta(111, 5, 7);
pauta.marcarFalta(111, 5, 23);
pauta.marcarFalta(222, 3, 12);
pauta.marcarFalta(222, 3, 21);
pauta.marcarFalta(222, 4, 9);
pauta.marcarFalta(222, 4, 16);
pauta.marcarFalta(222, 4, 25);
pauta.marcarFalta(222, 4, 30);
pauta.imprimir();
public class Turma {
static String nomeTurma;
String codigo;
String periodo;
ArrayList<Aluno> alunos = new ArrayList<>();
public Turma(String nomeTurma, String codigo, String periodo) {
this.nomeTurma = nomeTurma;
this.codigo = codigo;
this.periodo = periodo;
}
public void inserirAluno(Aluno a) {
alunos.add(a);
}
public static String getNomeTurma() {
return nomeTurma;
}
public void imprimir() {
for (Aluno b: alunos) {
System.out.println(b);
}
}
}
public class Aluno {
String nome;
int matricula;
public Aluno(String nome, int matricula) {
this.nome = nome;
this.matricula = matricula;
}
public String toString(){
return "Nome: " + this.nome + ", Matricula: " + this.matricula;
}
public int getMatricula() {
return matricula;
}
}
public class Pauta {
int mesInicial;
int mesFinal;
public Pauta(int mesInicial, int mesFinal, Turma turma) {
this.mesInicial = mesInicial;
this.mesFinal = mesFinal;
}
public void marcarFalta(int getMatricula, int mes, int dia) {
int i=0;
for (Aluno falta : alunos){
if (falta.getMatricula==getMatricula && falta.dia==dia){
i++;
}
}
return i;
}
public void imprimir() {
System.out.println("Mês inicial: "+this.mesInicial+ ",Mês Final: "+ this.mesFinal+",Turma: "+ Turma.getNomeTurma());
}
}
The Exit would be;
Matricula: 111, faltas:12;
Matricula: 222, faltas:6;
That is the mistake:
Exception in thread "main" java.lang.Error: Unresolved
compilation problems: alunos cannot be resolved to a variable getMatricula
cannot be resolved or is not a field getMatricula cannot be resolved to a
variable dia cannot be resolved or is not a field at
Gerenciar_frequencia.Pauta.marcarFalta(Pauta.java:12) at
Gerenciar_frequencia.Principal.main(Principal.java:11)
What is the problem that is occurring? any error? or the output is incorrect?
– Filipe L. Constante
I took a look at your code, there are many errors.
– Filipe L. Constante
Felipe L. Constante. Errors you found are all related to the Agenda class.
– Bruno