@@ -24,26 +24,30 @@ export class CallHandler {
24
24
* employeeLevels[1] = managers
25
25
* employeeLevels[2] = directors
26
26
*/
27
- this . employeeLevels = new Array ( LEVELS ) ;
27
+ this . employeeLevels = [ ] ;
28
+
29
+ this . callQueues = [ ] ;
28
30
/* queues for each call�s rank */
29
- this . callQueues = new Array ( LEVELS ) ;
30
-
31
+ for ( let i = 0 ; i < LEVELS ; i ++ ) {
32
+ this . callQueues . push ( [ ] ) ;
33
+ }
34
+
31
35
// Create respondents.
32
- let respondents = new Array ( NUM_RESPONDENTS ) ;
36
+ let respondents = [ ] ;
33
37
for ( let k = 0 ; k < NUM_RESPONDENTS - 1 ; k ++ ) {
34
38
respondents . push ( new Respondent ( this ) ) ;
35
39
}
36
- this . employeeLevels [ 0 ] = respondents ;
40
+ this . employeeLevels . push ( respondents ) ;
37
41
38
42
// Create managers.
39
- let managers = new Array ( NUM_MANAGERS ) ;
43
+ let managers = [ ] ;
40
44
managers . push ( new Manager ( this ) ) ;
41
- this . employeeLevels [ 1 ] = managers ;
45
+ this . employeeLevels . push ( managers ) ;
42
46
43
47
// Create directors.
44
- let directors = new Array ( NUM_DIRECTORS ) ;
48
+ let directors = [ ] ;
45
49
directors . push ( new Director ( this ) ) ;
46
- this . employeeLevels [ 2 ] = directors ;
50
+ this . employeeLevels . push ( directors ) ;
47
51
}
48
52
49
53
/* Gets the first available employee who can handle this call. */
@@ -75,7 +79,7 @@ export class CallHandler {
75
79
} else {
76
80
/* Place the call into corresponding call queue according to its rank. */
77
81
call . reply ( "Please wait for free employee to reply" ) ;
78
- callQueues [ call . getRank ( ) . getValue ( ) ] . push ( call ) ;
82
+ this . callQueues [ call . getRank ( ) ] . push ( call ) ;
79
83
}
80
84
}
81
85
@@ -84,7 +88,7 @@ export class CallHandler {
84
88
* if we were able to assign a call, false otherwise. */
85
89
assignCall ( emp ) {
86
90
/* Check the queues, starting from the highest rank this employee can serve. */
87
- for ( let rank = emp . getRank ( ) . getValue ( ) ; rank >= 0 ; rank -- ) {
91
+ for ( let rank = emp . getRank ( ) ; rank >= 0 ; rank -- ) {
88
92
let que = this . callQueues [ rank ] ;
89
93
90
94
/* Remove the first call, if any */
0 commit comments