annotate src/alice/test/dpp/codesegment/philosophy/EatCodeSegment.java @ 25:f77f0bb99f35

modify each CodeSegment
author one
date Tue, 15 Jan 2013 16:41:57 +0900
parents da62aa1f4d87
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23
da62aa1f4d87 hg rename codesegment package
one
parents: 20
diff changeset
1 package alice.test.dpp.codesegment.philosophy;
5
2db314b1a970 add EatCodeSegment TakeForkCodeSegment, ForkState, Table
one
parents:
diff changeset
2
2db314b1a970 add EatCodeSegment TakeForkCodeSegment, ForkState, Table
one
parents:
diff changeset
3 import alice.codesegment.CodeSegment;
12
bfaaebb50a2e modified Fork.java
one
parents: 6
diff changeset
4 import alice.datasegment.CommandType;
bfaaebb50a2e modified Fork.java
one
parents: 6
diff changeset
5 import alice.datasegment.Receiver;
20
6018e62cb198 modified
one
parents: 18
diff changeset
6 import alice.test.dpp.datasegment.Philosophy;
5
2db314b1a970 add EatCodeSegment TakeForkCodeSegment, ForkState, Table
one
parents:
diff changeset
7
2db314b1a970 add EatCodeSegment TakeForkCodeSegment, ForkState, Table
one
parents:
diff changeset
8 public class EatCodeSegment extends CodeSegment {
2db314b1a970 add EatCodeSegment TakeForkCodeSegment, ForkState, Table
one
parents:
diff changeset
9
12
bfaaebb50a2e modified Fork.java
one
parents: 6
diff changeset
10 Receiver arg1 = ids.create(CommandType.TAKE);
bfaaebb50a2e modified Fork.java
one
parents: 6
diff changeset
11
14
33727db069c2 add ScheduleCodeSegment. modified CodeSegment
one
parents: 12
diff changeset
12 public EatCodeSegment(String pName) {
33727db069c2 add ScheduleCodeSegment. modified CodeSegment
one
parents: 12
diff changeset
13 arg1.setKey(pName);
5
2db314b1a970 add EatCodeSegment TakeForkCodeSegment, ForkState, Table
one
parents:
diff changeset
14 }
2db314b1a970 add EatCodeSegment TakeForkCodeSegment, ForkState, Table
one
parents:
diff changeset
15
2db314b1a970 add EatCodeSegment TakeForkCodeSegment, ForkState, Table
one
parents:
diff changeset
16 @Override
2db314b1a970 add EatCodeSegment TakeForkCodeSegment, ForkState, Table
one
parents:
diff changeset
17 public void run() {
14
33727db069c2 add ScheduleCodeSegment. modified CodeSegment
one
parents: 12
diff changeset
18 Philosophy phil = arg1.asClass(Philosophy.class);
12
bfaaebb50a2e modified Fork.java
one
parents: 6
diff changeset
19 System.out.println(phil.getName() + " is eating.");
25
f77f0bb99f35 modify each CodeSegment
one
parents: 23
diff changeset
20 phil.setState(Philosophy.State.PUTFORK);
f77f0bb99f35 modify each CodeSegment
one
parents: 23
diff changeset
21 new PutForkCodeSegment(phil.getName(), phil.getRightFork(), phil.getLeftFork());
14
33727db069c2 add ScheduleCodeSegment. modified CodeSegment
one
parents: 12
diff changeset
22 ods.update("local", phil.getName(), phil);
5
2db314b1a970 add EatCodeSegment TakeForkCodeSegment, ForkState, Table
one
parents:
diff changeset
23 }
2db314b1a970 add EatCodeSegment TakeForkCodeSegment, ForkState, Table
one
parents:
diff changeset
24 }