Mercurial > hg > Members > nobuyasu > Alice > DPPAlice
annotate src/alice/test/dpp/datasegment/Fork.java @ 26:80023cb92594 draft
add some CodeSegment. ForkStateTake, CheckForkOwnerCodeSegment, TakeForkManager
author | one |
---|---|
date | Tue, 11 Dec 2012 16:07:41 +0900 |
parents | edd9ced13896 |
children |
rev | line source |
---|---|
19
dbc5c8e8e9c2
rename frome model to datasegment
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
15
diff
changeset
|
1 package alice.test.dpp.datasegment; |
3 | 2 |
7 | 3 import org.msgpack.annotation.Message; |
12 | 4 import org.msgpack.annotation.MessagePackOrdinalEnum; |
7 | 5 |
6 @Message | |
3 | 7 public class Fork { |
8 | |
12 | 9 |
10 private String forkName; | |
4 | 11 private String owner; |
7 | 12 private State state; |
13 | |
10 | 14 private final String TABLE = "TABLE"; |
12 | 15 |
16 @MessagePackOrdinalEnum | |
7 | 17 public enum State { |
18 ON_THE_TABLE, | |
19 IN_THE_HAND; | |
20 } | |
9 | 21 |
12 | 22 public Fork() {} |
3 | 23 |
4 | 24 public Fork(String n) { |
25 forkName = n; | |
10 | 26 owner = TABLE; |
7 | 27 state = State.ON_THE_TABLE; |
4 | 28 } |
29 | |
7 | 30 public State getState() { |
4 | 31 return state; |
32 } | |
12 | 33 |
4 | 34 public String getForkName() { |
35 return forkName; | |
36 } | |
12 | 37 |
24 | 38 public boolean takeFork(String pName) { |
15 | 39 if (state == State.ON_THE_TABLE) { |
7 | 40 state = State.IN_THE_HAND; |
14 | 41 owner = pName; |
4 | 42 return true; |
43 } else { | |
44 return false; | |
45 } | |
46 } | |
47 | |
14 | 48 public boolean onTheTable(String pName) { |
49 if (owner.equals(pName)) { | |
7 | 50 state = State.ON_THE_TABLE; |
10 | 51 owner = TABLE; |
4 | 52 return true; |
53 } else { | |
54 return false; | |
55 } | |
56 } | |
57 | |
26
80023cb92594
add some CodeSegment. ForkStateTake, CheckForkOwnerCodeSegment, TakeForkManager
one
parents:
24
diff
changeset
|
58 public boolean ownerEquals(String s) { |
80023cb92594
add some CodeSegment. ForkStateTake, CheckForkOwnerCodeSegment, TakeForkManager
one
parents:
24
diff
changeset
|
59 return owner.equals(s); |
80023cb92594
add some CodeSegment. ForkStateTake, CheckForkOwnerCodeSegment, TakeForkManager
one
parents:
24
diff
changeset
|
60 } |
80023cb92594
add some CodeSegment. ForkStateTake, CheckForkOwnerCodeSegment, TakeForkManager
one
parents:
24
diff
changeset
|
61 |
4 | 62 public String getOwner() { |
63 return owner; | |
64 } | |
65 | |
3 | 66 |
67 } |