-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClass Inheritance.js
46 lines (37 loc) · 1.46 KB
/
Class Inheritance.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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 Nurse extends HospitalEmployee {
constructor(name, certifications) {
super(name);
this._certifications = certifications;
}
/* Under the Nurse constructor(), add a getter that returns the value saved to the Nurse instance’s _certifications. */
get certifications() {
return this._certifications;
}
/* Add a method called addCertification under the certifications getter.
The method should accept one input (newCertification). Inside the method, use the push method to add the newCertification value to the nurse’s certifications array. */
addCertification(newCertification) {
this._certifications.push(newCertification);
}
}
const nurseOlynyk = new Nurse('Olynyk', ['Trauma', 'Pediatrics']);
nurseOlynyk.takeVacationDays(5);
/* At the bottom of main.js call the .addCertification() method on nurseOlynyk with a parameter of 'Genetics'. */
nurseOlynyk.addCertification('Genetics');
console.log(nurseOlynyk.remainingVacationDays);
/* Log the value saved to the certifications property of nurseOlynyk. */
console.log(nurseOlynyk.certifications);