0
Hello, everybody.
In the code below, when trying to change the value of the variable horasAula of function Professor through function setHorasAula and the value of the variable cargo of function Coordenador, the value you print on the screen is undefined, instead of the new value. The other get and teach functions work perfectly.
function Funcionario () {
var nome;
var matricula;
var sexo;
var dataNascimento;
var salario;
this.getNome = function () {
return this.nome;
};
this.setNome = function (nome) {
this.nome = nome;
};
this.getMatricula = function () {
return this.matricula;
};
this.setMatricula = function (matricula) {
this.matricula = matricula;
};
this.getSexo = function () {
return this.sexo;
};
this.setSexo = function (sexo) {
this.sexo = sexo;
};
this.getDataNascimento = function () {
return this.dataNascimento;
};
this.setDataNascimento = function (dataNascimento) {
this.dataNascimento = dataNascimento;
};
this.getSalario = function () {
return this.salario;
};
this.setSalario = function (salario) {
this.salario = salario;
};
this.receberSalario = function () {
return "Recebendo salário..."
}
}
function Professor () {
var horasAula;
this.getHorasAula = function () {
return horasAula;
};
this.setHorasAula = function (horasAula) {
this.horasAula = horasAula;
};
this.lecionar = function () {
return "Lecionando...";
};
}
function Coordenador () {
var cargo;
this.getCargo = function () {
return cargo;
};
this.setCargo = function (cargo) {
this.cargo = cargo;
};
this.criarTurma = function () {
var turma = {};
};
}
Professor.prototype = new Funcionario();
Professor.prototype.constructor = Professor;
Coordenador.prototype = new Professor();
Coordenador.prototype.constructor = Coordenador;
var fun = new Funcionario();
var prof = new Professor();
var coord = new Coordenador ();
fun.setDataNascimento(07081994);
console.log(fun.getDataNascimento());
prof.setNome("ola");
console.log(prof.getNome());
prof.setHorasAula(18);
console.log(prof.getHorasAula());
coord.setCargo("Auxiliar de Representante Ajudante Administrativo");
console.log(coord.getCargo());