Javascript Classes Inheritance II 7/12


#1
class HospitalEmployee {
  construtor(name) {
    this._name = name;
  }
  get name() {return this._name;}
}
class Doctor extends HospitalEmployee {
  construtor(name) {
    this._name = name;
    this._remainingVacationDays = 20;
    this._insurance = 'insurance';
  }
  get name() {return this._name;}
  get remainingVacationDays() {
    return this.remainingVacationDays;
  }
  takeVacationDays(dayOff) {
    this._remainingVacationDays-=dayOff;
  }
}
class Nurse extends HospitalEmployee {
  construtor(name) {
    this._name = name;
    this._remainingVacationDays = 20;
    this._certifications = 'cert';
  }
  get name() {return this._name;}
  get remainingVacationDays() {
    return this.remainingVacationDays;
  }
  takeVacationDays(dayOff) {
    this._remainingVacationDays-=dayOff;
  }
  addCertification() {}
}

Error : Did you add an empty constructor that accepts one argument called name?

Instructions :
1.
In the next few exercises, you will create two subclasses (Doctor and Nurse) from a parent class named HospitalEmployee. Below, we have listed the properties and methods you will find in the Doctor and Nurse classes.

DOCTOR
Properties: _name, _remainingVacationDays (set to 20 inside the constructor()), _insurance
Methods: .takeVacationDays()
NURSE
Properties: _name, _remainingVacationDays (set to 20 inside constructor()), _certifications
Methods: .takeVacationDays(), .addCertification()
In main.js, create a parent class named HospitalEmployee. Add a constructor with name as an argument.


#2

Your constructor doesn’t look empty? Sometimes, you can’t do multiply steps at once


#3

Thank you @stetim94 I got it.

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;
 }
}

class Doctor {
constructor(name, remainingVacationDays, insurance){
  this._name=name;
  this._remainingVacationDays=20;
  this._insurance=insurance;
}
 get name (){return this._name;}
 get remainingVacationDays (){
    return this._remainingVacationDays;
 }
 takeVacationDays (daysOff) {
   this._remainingVacationDays-=daysOff;
 }
}

class Nurse {
 constructor (name,remainingVacationDays, certifications ) {
   this._name=name;
   this._remainingVacationDays=20;
   this._certifications=certifications;
 }
  get name (){return this._name;}
  get remainingVacationDays (){
    return this._remainingVacationDays;
  }
 takeVacationDays (daysOff) {
   this._remainingVacationDays-=daysOff;
 }
  addCertification(){}
}