Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 20, 2020 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/c1ac83462096fb42c717a8fa6e429f2c to your computer and use it in GitHub Desktop.
Save codecademydev/c1ac83462096fb42c717a8fa6e429f2c to your computer and use it in GitHub Desktop.
Codecademy export
class HospitalEmployee {
constructor(name) {
this._name = name;
this._remainingVacationDays = 20;
}
get name() {
return this._name;
}
get remainingVacationDays() {
return this._remainingVacationDays;
}
takeVacationDays(daysOff) {
this._remainingVacationDays -= daysOff;
}
static generatePassword(){
const number = Math.floor(Math.random() * 10000);
return number;
}
}
class Nurse extends HospitalEmployee {
constructor(name, certifications) {
super(name);
this._certifications = certifications;
}
get certifications() {
return this._certifications;
}
addCertification(newCertification) {
this.certifications.push(newCertification);
}
}
class Doctor extends HospitalEmployee {
constructor(name, insurance){
super(name);
this._remainingVacationDays = 20;
this._insurance = insurance;
}
get insurance() {
return this._insurance;
}
addInsurance(newInsurance) {
this._insurance.push(newInsurance);
}
addPassword(){
this.passWord = HospitalEmployee.generatePassword();
}
}
const nurseOlynyk = new Nurse('Olynyk', ['Trauma','Pediatrics']);
const doctorAppleby = new Doctor('Appleby', ['malpractice', 'lawsuits', 'income']);
nurseOlynyk.takeVacationDays(5);
nurseOlynyk.addCertification('Genetics');
console.log(nurseOlynyk);
doctorAppleby.takeVacationDays(7);
doctorAppleby.addInsurance('health');
doctorAppleby.addPassword();
console.log(doctorAppleby);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment