-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cook.java
56 lines (49 loc) · 1.3 KB
/
Cook.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
44
45
46
47
48
49
50
51
52
53
54
55
56
public class Cook extends RestaurantMember {
Cook(String firstName, String secondName) {
super(firstName, secondName);
setName("Cook:"+firstName+' '+secondName);
}
public void run()
{
CookMessage("been started");
while(getLoggedIn())
{
//refactor
Order order = OrderController.INSTANCE.GetNextItemOffQueue();
if(order == null)
{
CookMessage("no current orders");
//thread will now wait for 7 seconds
/*
try {
wait((long)7000);
} catch (InterruptedException e) {
e.printStackTrace();
}*/
//TODO: would be nice to do this with wait
try {
sleep(CookController.INSTANCE.GetRandomWaitTime());
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
//return item to cashier
CookMessage("has taken item off queue");
order.setOrderStatus(OrderStatus.preperation);
//prepare the item
try {
sleep(CookController.INSTANCE.GetRandomWaitTime());
} catch (InterruptedException e) {
e.printStackTrace();
}
order.setOrderStatus(OrderStatus.cooked);
}
}
//TODO: if they still have incomplete orders do something
}
public void CookMessage(String action)
{
System.out.println("Cook:"+ this.getMemberName() + " has " + action + ".");
}
}