-
Notifications
You must be signed in to change notification settings - Fork 1
/
7-8-Person.js
56 lines (49 loc) Β· 934 Bytes
/
7-8-Person.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
/**
* p272 μμ
*/
class Person {
#name;
#department;
constructor(name, department) {
this.#name = name;
this.#department = department;
}
get name() {
return this.#name;
}
get department() {
return this.#department;
}
}
class Department {
#chargeCode;
#manager;
constructor(chargeCode, manager) {
this.#chargeCode = chargeCode;
this.#manager = manager;
}
get chargeCode() {
return this.#chargeCode;
}
set chargeCode(arg) {
this.#chargeCode = arg;
}
get manager() {
return this.#manager;
}
set manager(arg) {
this.#manager = arg;
}
}
/**
* μμ μ€νμ μν μμμ μ½λ
*/
const name = 'λ§ν΄ νμΈλ¬';
const chargeCode = 'AA';
const manager = 'λ λ² μΉ΄ νμ¨μ€';
const person = new Person(name, new Department(chargeCode, manager));
console.log(
person.name,
person.department.chargeCode,
person.department.manager
);