forked from careercup/ctci
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCall.java
More file actions
52 lines (42 loc) · 1.04 KB
/
Call.java
File metadata and controls
52 lines (42 loc) · 1.04 KB
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
package Question8_2;
/* Represents a call from a user. Calls have a minimum rank and are assigned to the
* first employee who can handle that call.
*/
public class Call {
/* Minimal rank of employee who can handle this call. */
private Rank rank;
/* Person who is calling. */
private Caller caller;
/* Employee who is handling call. */
private Employee handler;
public Call(Caller c) {
rank = Rank.Responder;
caller = c;
}
/* Set employee who is handling call. */
public void setHandler(Employee e) {
handler = e;
}
/* Play recorded message to the customer. */
public void reply(String message) {
System.out.println(message);
}
public Rank getRank() {
return rank;
}
public void setRank(Rank r) {
rank = r;
}
public Rank incrementRank() {
if (rank == Rank.Responder) {
rank = Rank.Manager;
} else if (rank == Rank.Manager) {
rank = Rank.Director;
}
return rank;
}
/* Disconnect call. */
public void disconnect() {
reply("Thank you for calling");
}
}