I would like to create a method in my Teacher class that calculates your salary based on your workload , which is an established function in the Discipline class, a teacher can teach a variety of subjects, the hourly loads of each discipline he teaches were accumulated in a variable, so that from there he could multiply by the value of the hour class and get his salary, however, the way I'm trying to do is giving error, help me please :
Class Teacher
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;
}
}