-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServe.java
More file actions
31 lines (25 loc) · 915 Bytes
/
Serve.java
File metadata and controls
31 lines (25 loc) · 915 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
package cs2030.simulator;
import java.util.Optional;
import cs2030.util.Pair;
class Serve extends Event {
private final Server server;
Serve(Customer customer, double eventTime, Server server) {
super(customer, eventTime);
this.server = server;
}
@Override
Pair<Optional<Event>, Shop> execute(Shop shop) {
Customer customer = super.getCustomer();
Server server = shop.get(this.server.getID() - 1);
return Pair.<Optional<Event>, Shop>of(
Optional.<Event>of(new Done(customer,
customer.getFinishTime(),
server)),
shop.serve(server, customer, customer.getFinishTime()));
}
@Override
public String toString() {
return String.format("%s %s serves by %s", super.toString(),
super.getCustomer().toString(), this.server.toString());
}
}