0
I would like to create a method in my class Teacher that would calculate your salary based on your workload, which is a function established in the Discipline class, a teacher can teach several disciplines, so I would like the workloads of each discipline he teaches to be accumulated in one variable, so that from then on I could multiply by the value of the hour lesson and get your salary, however, the way I’m trying to do is giving error, please help me:
teacher class
package agregacao;
public class Professor {
private String nome;
private double cpf, salario;
private Disciplina disciplina;
public Professor(String nome, double cpf, Disciplina disciplina) {
this.nome = nome;
this.cpf = cpf;
this.disciplina = disciplina;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getNome() {
return this.nome;
}
public void setCpf(double cpf) {
this.cpf = cpf;
}
public double getCpf() {
return this.cpf;
}
public void calcSalario() {
int carga += this.disciplina.getCargaHoraria();//O erro está nessa linha
}
}
class Discipline
package agregacao;
public class Disciplina {
private String nomeDisciplina;
private int cargaHoraria;
public void setNomeDisciplina(String nomeDisciplina) {
this.nomeDisciplina = nomeDisciplina;
}
public String getNomeDisciplina() {
return this.nomeDisciplina;
}
public void setCargaHoraria(int cargaHoraria) {
this.cargaHoraria = cargaHoraria;
}
public int getCargaHoraria() {
return this.cargaHoraria;
}
}
but with me access my method of Discipline getCargaHoraria(); thus?
– dotNetJr