Mercurial > hg > Members > nobuyasu > Alice > DPPAlice
view src/alice/test/dpp/codesegment/TakeLeftForkCodeSegment.java @ 17:92cde6277018
modified each CodeSegment linkage
author | one |
---|---|
date | Sun, 09 Dec 2012 22:37:44 +0900 |
parents | f5c2fad58b7e |
children | f0a2e2d2094e |
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 TakeLeftForkCodeSegment extends CodeSegment { Receiver arg1 = ids.create(CommandType.TAKE); Receiver arg2 = ids.create(CommandType.TAKE); public TakeLeftForkCodeSegment(String pName, String forkName) { arg1.setKey(pName); arg2.setKey(forkName); } @Override public void run() { Philosophy phil = arg1.asClass(Philosophy.class); Fork fork = arg2.asClass(Fork.class); if (fork.getFork(phil.getName())) { phil.setState(Philosophy.State.EAT); new EatCodeSegment(phil.getName()); } else { new TakeLeftForkCodeSegment(phil.getName(), phil.getLeftFork()); } ods.update("local", phil.getName(), phil); ods.update("local", fork.getForkName(), fork); } }