-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServeEvent.java
More file actions
35 lines (29 loc) · 1.08 KB
/
ServeEvent.java
File metadata and controls
35 lines (29 loc) · 1.08 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
class ServeEvent extends Event {
private final int subIndex;
private final Server server;
private final double serviceTime;
ServeEvent(double time, double serviceTime, Customer customer, int subIndex,
Server server) {
super(time, customer);
this.subIndex = subIndex;
this.server = server;
this.serviceTime = serviceTime;
}
public int updateNumServed(int numServed) {
return numServed + 1;
}
public boolean hasNextEvent() {
return true;
}
public Event nextEvent(ImList<Server> serverList) {
return new DoneEvent(this.time + this.serviceTime, this.customer,
this.subIndex, this.server);
}
public ImList<Server> updateServerList(ImList<Server> serverList) {
return serverList.set(server.getIndex(), serverList.get(server.getIndex()).dequeue()
.updateAvailableTime(subIndex, this.time + this.serviceTime));
}
public String toString() {
return super.toString() + "serves by " + server.toString(subIndex) + "\n";
}
}