-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWaitEvent.java
More file actions
31 lines (25 loc) · 942 Bytes
/
WaitEvent.java
File metadata and controls
31 lines (25 loc) · 942 Bytes
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
class WaitEvent extends Event {
private final Server server;
private final double waitingTime;
WaitEvent(double time, double waitingTime, Customer customer, Server server) {
super(time, customer);
this.waitingTime = waitingTime;
this.server = server;
}
public double updateTotalWaitingTime(double totalWaitingTime) {
return totalWaitingTime + waitingTime;
}
public boolean hasNextEvent() {
return true;
}
public Event nextEvent(ImList<Server> serverList) {
return new QueueEvent(this.time + this.waitingTime, 0.0,
this.customer, this.server);
}
public ImList<Server> updateServerList(ImList<Server> serverList) {
return serverList.set(server.getIndex(), serverList.get(server.getIndex()).enqueue());
}
public String toString() {
return super.toString() + "waits at " + server.toString(0) + "\n";
}
}