-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path11-8-Employee.js
56 lines (45 loc) Β· 974 Bytes
/
11-8-Employee.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
/**
* p446 μμ
*/
class Employee {
#name;
#typeCode;
constructor(name, typeCode) {
this.#name = name;
this.#typeCode = typeCode;
}
get name() {
return this.#name;
}
get type() {
return Employee.legalTypeCodes[this.#typeCode];
}
static get legalTypeCodes() {
return { E: 'Engineer', M: 'Manager', S: 'Salesperson' };
}
}
function createEmployee(name, typeCode) {
return new Employee(name, typeCode);
}
function createEngineer(name) {
return new Employee(name, 'E');
}
/**
* μμ μ€νμ μν μμμ μ½λ
*/
const document = {
name: 'λ§ν΄ νμΈλ¬',
empType: 'M',
leadEngineer: 'λ λ² μΉ΄ νμ¨μ€',
};
let candidate;
/**
* μμ νΈμΆ (1)
*/
candidate = createEmployee(document.name, document.empType);
console.log(candidate.name, candidate.type);
/**
* μμ νΈμΆ (2)
*/
const leadEngineer = createEngineer(document.leadEngineer);
console.log(leadEngineer.name, leadEngineer.type);