Mercurial > hg > Members > nobuyasu > Alice > DPPAlice
changeset 7:f7af6388adbb
modified Fork.java
author | one |
---|---|
date | Sun, 25 Nov 2012 17:33:42 +0900 |
parents | b59c04a332a1 |
children | 288086a40539 |
files | src/alice/test/dpp/codesegment/PutForkCodeSegment.java src/alice/test/dpp/model/Fork.java src/alice/test/dpp/model/ForkState.java |
diffstat | 3 files changed, 21 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/test/dpp/codesegment/PutForkCodeSegment.java Sun Nov 25 17:22:45 2012 +0900 +++ b/src/alice/test/dpp/codesegment/PutForkCodeSegment.java Sun Nov 25 17:33:42 2012 +0900 @@ -25,6 +25,8 @@ Fork rightFork = arg2.asClass(Fork.class); leftFork.onTheTable(phil); rightFork.onTheTable(phil); + ods.update("local", leftFork.getForkName(), leftFork); + ods.update("local", rightFork.getForkName(), rightFork); new ThinkCodeSegment(phil); }
--- a/src/alice/test/dpp/model/Fork.java Sun Nov 25 17:22:45 2012 +0900 +++ b/src/alice/test/dpp/model/Fork.java Sun Nov 25 17:33:42 2012 +0900 @@ -1,18 +1,27 @@ package alice.test.dpp.model; +import org.msgpack.annotation.Message; + +@Message public class Fork { + private final String forkName; private String owner; - private String forkName; - private ForkState state; + private State state; + + @Message + public enum State { + ON_THE_TABLE, + IN_THE_HAND; + } public Fork(String n) { forkName = n; owner = Table.TABLE; - state = ForkState.ON_THE_TABLE; + state = State.ON_THE_TABLE; } - public ForkState getState() { + public State getState() { return state; } @@ -21,8 +30,8 @@ } public boolean getFork(Philosophy phil) { - if (state == ForkState.ON_THE_TABLE){ - state = ForkState.IN_THE_HAND; + if (state == State.ON_THE_TABLE){ + state = State.IN_THE_HAND; owner = phil.getName(); return true; } else { @@ -32,7 +41,7 @@ public boolean onTheTable(Philosophy phil) { if (owner.equals(phil.getName())) { - state = ForkState.ON_THE_TABLE; + state = State.ON_THE_TABLE; owner = Table.TABLE; return true; } else {
--- a/src/alice/test/dpp/model/ForkState.java Sun Nov 25 17:22:45 2012 +0900 +++ b/src/alice/test/dpp/model/ForkState.java Sun Nov 25 17:33:42 2012 +0900 @@ -1,11 +1,11 @@ package alice.test.dpp.model; +import org.msgpack.annotation.Message; + +@Message public enum ForkState { - ON_THE_TABLE, IN_THE_HAND; - - }