Mercurial > hg > Members > nobuyasu > Alice > DPPAlice
view src/alice/test/dpp/codesegment/EatCodeSegment.java @ 13:888388e47fe5
modified ThinkCodeSegment. remove random, sleep
author | one |
---|---|
date | Wed, 28 Nov 2012 16:21:34 +0900 |
parents | bfaaebb50a2e |
children | 33727db069c2 |
line wrap: on
line source
package alice.test.dpp.codesegment; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; import alice.test.dpp.model.Fork; import alice.test.dpp.model.Philosophy; public class EatCodeSegment extends CodeSegment { Philosophy phil; Receiver arg1 = ids.create(CommandType.TAKE); Receiver arg2 = ids.create(CommandType.TAKE); public EatCodeSegment(Philosophy p) { phil = p; arg1.setKey(phil.getLeftFork()); arg2.setKey(phil.getRightFork()); } @Override public void run() { System.out.println(phil.getName() + " is eating."); Fork leftFork = arg1.asClass(Fork.class); Fork rightFork = arg2.asClass(Fork.class); new PutForkCodeSegment(phil); ods.update("local", leftFork.getForkName(), leftFork); ods.update("local", rightFork.getForkName(), rightFork); } }