Last change
on this file since 265 was 263, checked in by Faria Nassiri Mofakham, 5 years ago |
Offer class updated; Message enum created; parapoloid tried in GUI; some small changes in some previous classes (Bundle, stack,.. ); UF_Silly renamed to UF_Crazy; started to add role to UF classes...
|
File size:
973 bytes
|
Rev | Line | |
---|
[263] | 1 | /**
|
---|
| 2 | *
|
---|
| 3 | */
|
---|
| 4 | package onetomany.bargainingchipsgame.interactions;
|
---|
| 5 |
|
---|
| 6 | /**
|
---|
| 7 | * Message is an ENUM which its value is either `bid', `accept', or `end'. Any other value means a null.
|
---|
| 8 | *
|
---|
| 9 | *
|
---|
| 10 | * @author Faria Nassiri-Mofakham
|
---|
| 11 | *
|
---|
| 12 | */
|
---|
| 13 | public enum Message {
|
---|
| 14 | BID("B"), ACCEPT("A"), END("E"), OTHER;
|
---|
| 15 | // message codes: `bid' [body contains a bundle], `accept' [agree with the deal (based on the rules); null body],
|
---|
| 16 | // `end' [quitting the negotiation; null body]
|
---|
| 17 | private String key;
|
---|
| 18 |
|
---|
| 19 | Message(String k)
|
---|
| 20 | {
|
---|
| 21 | this.key = k;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | //default constructor, used only for the OTHER case,
|
---|
| 25 | //because OTHER doesn't need a key to be associated with.
|
---|
| 26 | Message()
|
---|
| 27 | {
|
---|
| 28 |
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | Message getKey(String x) {
|
---|
| 32 | if ("B".equals(x)) { return BID; }
|
---|
| 33 | else if ("A".equals(x)) { return ACCEPT; }
|
---|
| 34 | else if (x == null) { return OTHER; }
|
---|
| 35 | else throw new IllegalArgumentException();
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.