/** * */ package onetomany.bargainingchipsgame.interactions; /** * Message is an ENUM which its value is either `bid', `accept', or `end'. Any other value means a null. * * * @author Faria Nassiri-Mofakham * */ public enum Message { BID("B"), ACCEPT("A"), END("E"), OTHER; // message codes: `bid' [body contains a bundle], `accept' [agree with the deal (based on the rules); null body], // `end' [quitting the negotiation; null body] private String key; Message(String k) { this.key = k; } //default constructor, used only for the OTHER case, //because OTHER doesn't need a key to be associated with. Message() { } Message getKey(String x) { if ("B".equals(x)) { return BID; } else if ("A".equals(x)) { return ACCEPT; } else if (x == null) { return OTHER; } else throw new IllegalArgumentException(); } }