Guest User

Untitled

a guest
Jan 21st, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. class HospitalEmployee {
  2. constructor(name) {
  3. this._name = name;
  4. this._remainingVacationDays = 20;
  5. }
  6.  
  7. get name() {
  8. return this._name;
  9. }
  10.  
  11. get remainingVacationDays() {
  12. return this._remainingVacationDays;
  13. }
  14.  
  15. takeVacationDays(daysOff) {
  16. this._remainingVacationDays -= daysOff;
  17. }
  18. static generatePassword(){
  19. return Math.floor(Math.random()*10000);
  20. }
  21. }
  22.  
  23. class Nurse extends HospitalEmployee {
  24. constructor(name, certifications) {
  25. super(name);
  26. this._certifications = certifications;
  27. }
  28.  
  29. get certifications() {
  30. return this._certifications;
  31. }
  32.  
  33. addCertification(newCertification) {
  34. this.certifications.push(newCertification);
  35. }
  36. }
  37.  
  38. const nurseOlynyk = new Nurse('Olynyk', ['Trauma','Pediatrics']);
  39. nurseOlynyk.takeVacationDays(5);
  40. console.log(nurseOlynyk.remainingVacationDays);
  41. nurseOlynyk.addCertification('Genetics');
  42. console.log(nurseOlynyk.certifications);
Add Comment
Please, Sign In to add comment