-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArriveEvent.java
More file actions
31 lines (28 loc) · 1.03 KB
/
ArriveEvent.java
File metadata and controls
31 lines (28 loc) · 1.03 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
class ArriveEvent extends Event {
ArriveEvent(double time, Customer customer) {
super(time, customer);
}
public boolean hasNextEvent() {
return true;
}
public Event nextEvent(ImList<Server> serverList) {
for (int i = 0; i < serverList.size(); i++) {
int flag = serverList.get(i).checkAvailable(this.time);
if (flag != -1) {
double serviceTime = customer.getServiceTime();
return new ServeEvent(this.time, serviceTime, this.customer, flag,
serverList.get(i));
}
}
for (int i = 0; i < serverList.size(); i++) {
if (serverList.get(i).checkQueue()) {
return new WaitEvent(this.time, serverList.get(i).requiredWaitingTime(this.time),
this.customer, serverList.get(i));
}
}
return new LeaveEvent(this.time, this.customer);
}
public String toString() {
return super.toString() + "arrives" + "\n";
}
}