Hello, everyone.
I have the class Students, StudentMonitor and StudentImagination. These last two classes inherit all Student class methods and attributes (name, enrollment, gender, notes, display (), assignNote (), readNote (), calculateMedia ()) and add new ones to them.
How can I create these two last classes so that the Student class is their parent?
var Estudante = function (nome, matricula, sexo) {
this.nome = nome;
this.matricula = matricula;
this.sexo = sexo;
var notas = [];
this.exibir = function () {
return "oi";
};
this.atribuirNota = function (n) {
nota.push(n);
};
this.lerNota = function (index) {
return [index-1];
};
calcularMedia = function () {
var x = (notas.length);
var soma = 0;
for (i=0; i<(x - 1); i++ ){
soma += notas[i];
}
var media = soma / x;
return media;
}
}
var EstudanteMonitor = Object.create(Estudante);
EstudanteMonitor.prototype.constructor = EstudanteMonitor;
var e1 = new EstudanteMonitor("oi", 2, 3);
console.log(e1.nome);
An example of how I'm trying to do.