@@ -15,17 +15,42 @@ class Department {
15
15
// this.id = '2'; // readonly์ด๊ธฐ ๋๋ฌธ์ error๊ฐ ๋ฐ์ํ๋ค.
16
16
this . employees . push ( employee ) ;
17
17
}
18
- printEmployeeInformation ( ) {
19
- console . log ( this . employees . length ) ;
20
- console . log ( this . employees ) ;
18
+ }
19
+
20
+ class ITDepartment extends Department {
21
+ admins : string [ ] ;
22
+ constructor ( id : string , public admin : string [ ] ) {
23
+ super ( id , 'IT' ) ;
24
+ this . admins = admin ;
25
+ }
26
+ }
27
+
28
+ class AccountingDepartment extends Department {
29
+ constructor ( id : string , private reports : string [ ] ) {
30
+ super ( id , 'Account' ) ;
31
+ }
32
+
33
+ addReport ( text : string ) {
34
+ this . reports . push ( text ) ;
35
+ }
36
+
37
+ printReports ( ) {
38
+ console . log ( this . reports ) ;
21
39
}
22
40
}
23
41
24
42
const accounting = new Department ( '1' , 'Accounting' ) ;
43
+ const ITaccounting = new ITDepartment ( '2' , [ 'Max' ] ) ;
25
44
26
- accounting . addEmployee ( 'Max' ) ;
27
- accounting . addEmployee ( 'Manu' ) ;
45
+ ITaccounting . addEmployee ( 'Max' ) ;
46
+ ITaccounting . addEmployee ( 'Manu' ) ;
28
47
29
48
// accounting.employees[2] = 'Anna';
30
- accounting . describe ( ) ;
31
- accounting . printEmployeeInformation ( ) ;
49
+ ITaccounting . describe ( ) ;
50
+ ITaccounting . printEmployeeInformation ( ) ;
51
+
52
+ const NewAccounting = new AccountingDepartment ( 'd2' , [ ] ) ;
53
+
54
+ NewAccounting . addReport ( 'Something went wrong...' ) ;
55
+
56
+ NewAccounting . printReports ( ) ;
0 commit comments