-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServerBackEvent.java
36 lines (33 loc) · 1.33 KB
/
ServerBackEvent.java
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
package cs2030.simulator;
/**
* ServerBackEvent where the server comes back from a break. The
* 'ServerBackEvent' supports operators that includes: (i) Transition to
* IdleEvent or ServeEvent depending on the state of the server.
* ServerBackEvent contains EventStatus status.
*/
public class ServerBackEvent extends Event {
private static final EventStatus status = EventStatus.SERVERBACK;
/**
* Constructs a ServerBackEvent containing a customer and a server, and an
* execute method to transition to the next events: (i) IdleEvent if the
* server has an empty queue. (ii) ServerEvent if server has customers in
* the queue.
* @param customer the latest customer that was served by this server.
* @param server Server who was taking a rest.
*/
public ServerBackEvent(Customer customer, ServerI server) {
super(customer, server.getNextAvailableTime(), server, shop -> {
ServerI s = shop.get(server).get();
s = s.doneRest();
return Pair.of(shop.replace(s), new IdleEvent(customer, s));
}, status);
}
/**
* This should not be accessed. Print an error message if it is.
* @return Error message.
*/
@Override
public String toString() {
return "This should not be printed";
}
}