Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created June 19, 2020 19:17
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/fcf0314f5cd82c8f06d12d2456e3dbad to your computer and use it in GitHub Desktop.
Save codecademydev/fcf0314f5cd82c8f06d12d2456e3dbad 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() {
return Math.floor(Math.random() * 10000);
}
}
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;
}
}
const doctorPain = new Doctor('Pain','Blue Cross');
doctorPain.takeVacationDays(10);
console.log(doctorPain.name);
console.log(doctorPain.insurance);
console.log(doctorPain.remainingVacationDays);
const nurseOlynyk = new Nurse('Olynyk', ['Trauma','Pediatrics']);
nurseOlynyk.takeVacationDays(5);
//console.log(nurseOlynyk.remainingVacationDays);
nurseOlynyk.addCertification('Genetics');
//console.log(nurseOlynyk.certifications);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment