-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrive.java
More file actions
38 lines (32 loc) · 966 Bytes
/
Arrive.java
File metadata and controls
38 lines (32 loc) · 966 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
32
33
34
35
36
37
38
class Arrive extends Event {
private static final int PRIORITY = 4;
Arrive(Shop shop, Customer customer, double time) {
super(shop, customer, time);
}
@Override
public Event getNextEvent(Shop shop) {
Shop newShop = shop.newCustomer(customer, time);
if (shop == newShop) {
return new Leave(shop, customer, time);
} else if (newShop.isCustomerInQueue(customer)) {
return new Wait(newShop, customer, time);
} else {
return new Served(newShop, customer, time);
}
}
@Override
public int getServerId() {
return 0;
}
@Override
public ImList<Double> updateStatistics(ImList<Double> statistics) {
return statistics;
}
public int getPriority() {
return PRIORITY;
}
@Override
public String toString() {
return String.format("%.3f ",this.time) + customer.toString() + " arrives";
}
}