package onetomany.bargainingchipsgame.interactions; import onetomany.bargainingchipsgame.Bundle; /** * An offer has two parts: (1) a bundle or null, (2) a message code: `bid', `accept', `end'. * When the code is 'bid', the first part is checked; for the two latter codes, the first part of the offer is null. * In other words, message `bid' means that offer contains a bundle which is proposed, `accept' means offer contains no bundle to propose, * but an agreement with the deal (the received offer), and `end' again means that nothing to propose, and quitting the negotiation. * * */ public class Offer { /** * Message codes: * (1) `bid' [body contains a bundle], * (2) `accept' [agree with the deal (based on the rules); null body], * (3) `end' [quitting the negotiation; null body] */ protected MessageType type; protected Bundle bundle; public Offer() { } /** * Creates a bid */ public Offer(Bundle b) { bundle = b; type = MessageType.BID; } /** * @return the proposal */ public Bundle getBundle() { return bundle; } @Override public String toString() { if (type != MessageType.BID) return type.toString(); else return type.toString() + ": " + bundle.toString(); } }