23
|
1 package alice.test.dpp.codesegment.philosophy;
|
5
|
2
|
|
3 import alice.codesegment.CodeSegment;
|
12
|
4 import alice.datasegment.CommandType;
|
|
5 import alice.datasegment.Receiver;
|
20
|
6 import alice.test.dpp.datasegment.Philosophy;
|
5
|
7
|
|
8 public class EatCodeSegment extends CodeSegment {
|
|
9
|
12
|
10 Receiver arg1 = ids.create(CommandType.TAKE);
|
|
11
|
14
|
12 public EatCodeSegment(String pName) {
|
|
13 arg1.setKey(pName);
|
5
|
14 }
|
|
15
|
|
16 @Override
|
|
17 public void run() {
|
14
|
18 Philosophy phil = arg1.asClass(Philosophy.class);
|
12
|
19 System.out.println(phil.getName() + " is eating.");
|
25
|
20 phil.setState(Philosophy.State.PUTFORK);
|
|
21 new PutForkCodeSegment(phil.getName(), phil.getRightFork(), phil.getLeftFork());
|
14
|
22 ods.update("local", phil.getName(), phil);
|
5
|
23 }
|
|
24 }
|