-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects_classes.js
68 lines (59 loc) · 1.7 KB
/
objects_classes.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class HospitalEmployee {
constructor(name) {
this._name = name;
this._remainingVacationDays = 20;
}
get name() {
return this._name;
}
get remainingVacationDays() {
return this._remainingVacationDays;
}
takeVacationDays(daysOff) {
if(daysOff > 20){
daysOff -= 20;
const finePerDay = daysOff * 30;
console.log('You exceed the vacation days by ' + daysOff + '. Now you have a fine for $' + finePerDay);
}
else {
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._insurance = insurance;
}
get insurance() {
return this._insurance;
}
addInsurance(amount){
this._insurance = amount;
}
}
const nurseOlynyk = new Nurse('Olynyk', ['Trauma','Pediatrics']);
const doctorDrew = new Doctor('Drew', 5000);
doctorDrew.takeVacationDays(20);
console.log('Doctor: ' + doctorDrew.name + '. ' + doctorDrew.remainingVacationDays + ' vacation days remaining');
doctorDrew.addInsurance(10000);
console.log('Insurance amount: $' + doctorDrew.insurance);
//nurseOlynyk.takeVacationDays(5);
//console.log(nurseOlynyk.remainingVacationDays);
//nurseOlynyk.addCertification('Genetics');
//console.log(nurseOlynyk.certifications);