-
Notifications
You must be signed in to change notification settings - Fork 0
/
Barmaid.jr
37 lines (32 loc) · 1.14 KB
/
Barmaid.jr
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
import edu.ucdavis.jr.*;
import java.util.HashMap;
public class Barmaid extends Server {
public Barmaid (cap Resource (Constants.Order, MyTime) orderQueue,
cap void () closingTime,
Clock clock,
cap void (MyTime) statistics,
ServingArea sa
) {
super(orderQueue, closingTime, clock, statistics, sa);
}
/* Serves orders and sends statistics */
private process serve {
Resource drink = null;
boolean closed = false;
while (!closed) {
inni Resource orderQueue(Constants.Order order, MyTime orderStartTime) st closingTime.length() == 0 {
switch (order) {
case BEER : drink = getBeer(); break;
case CAPPU : drink = getCappu(); break;
case CHOCO : drink = getChoco(); break;
}
send statistics(new MyTime(clock.getTime().compareTo(orderStartTime)));
return drink;
}
[] void closingTime() {
System.out.println("\n----------------------------------> Barmaid acknowledges closure.");
closed = true;
}
} // -- end while
}
}