-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy path04-Getters.js
More file actions
44 lines (36 loc) · 791 Bytes
/
04-Getters.js
File metadata and controls
44 lines (36 loc) · 791 Bytes
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
class Person {
static get species() {
return 'Homo sapiens';
}
static speciesSentence() {
return `Humans are classified as ${this.species}`
}
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.hasJob = false;
}
fullName() {
return `${this.firstName} ${this.lastName}`;
}
setFirstName(firstName) {
this.firstName = firstName;
}
setLastName(lastName) {
this.lastName = lastName;
}
}
class Worker extends Person {
constructor(firstName, lastName, job) {
super(firstName, lastName);
this.job = job;
this.hasJob = true;
}
setJob(job) {
this.job = job;
}
get biography() {
const bio = `${this.fullName()} is a ${this.job}`.toUpperCase();
return bio;
}
}