-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSelfCheckout.java
43 lines (37 loc) · 1.4 KB
/
SelfCheckout.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
37
38
39
40
41
42
43
package cs2030.simulator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.LinkedList;
import java.util.Optional;
class SelfCheckout extends Server {
static SelfCheckout createSelfCheckout(int serverId,
Queue<Customer> sharedQueue, int maxQueueLength) {
return new SelfCheckout(serverId, maxQueueLength,
sharedQueue, new LinkedList<Double>(),
Optional.<Customer>empty(), 0);
}
protected SelfCheckout(int serverId, int maxQueueLength,
Queue<Customer> customerQueue, Queue<Double> restTimes,
Optional<Customer> customerServiced,
double nextServiceTime) {
super(serverId, maxQueueLength, customerQueue,
restTimes, customerServiced, nextServiceTime);
}
@Override
protected SelfCheckout update(
Queue<Customer> customerQueue,
Optional<Customer> customerServiced,
double nextServiceTime) {
return new SelfCheckout(this.getServerId(), this.getMaxQueueLength(),
customerQueue, this.getRestTimes(),
customerServiced,
nextServiceTime);
}
@Override double estimateServeTime(Customer customer) {
return this.getNextServiceTime();
}
@Override
public String toString() {
return String.format("self-check %d", this.getServerId());
}
}