Static Methods
Wed Aug 17 2022 15:19:37 GMT+0000 (Coordinated Universal Time)
Saved by
@cruz
#javascript
class HospitalEmployee {
constructor(name) {
this._name = name;
this._remainingVacationDays = 20;
}
static generatePassword() {
const randomNumber = Math.floor(Math.random()*5);
return randomNumber;
}
get name() {
return this._name;
}
get remainingVacationDays() {
return this._remainingVacationDays;
}
takeVacationDays(daysOff) {
this._remainingVacationDays -= daysOff;
}
}
class Nurse extends HospitalEmployee {
constructor(name, certifications) {
super(name);
this._certifications = certifications;
}
get certifications() {
return this._certifications;
}
addCertification(newCertification) {
this.certifications.push(newCertification);
}
}
const nurseOlynyk = new Nurse('Olynyk', ['Trauma','Pediatrics']);
nurseOlynyk.takeVacationDays(5);
console.log(nurseOlynyk.remainingVacationDays);
nurseOlynyk.addCertification('Genetics');
console.log(nurseOlynyk.certifications);
content_copyCOPY
Comments