Rev | Line | |
---|
[253] | 1 | package onetomany.bargainingchipsgame.interactions;
|
---|
[237] | 2 |
|
---|
[253] | 3 | import onetomany.bargainingchipsgame.Bundle;
|
---|
[237] | 4 |
|
---|
| 5 | /**
|
---|
[263] | 6 | * An offer has two parts: (1) a bundle or null, (2) a message code: `bid', `accept', `end'.
|
---|
[237] | 7 | * When the code is 'bid', the first part is checked; for the two latter codes, the first part of the offer is null.
|
---|
[263] | 8 | * In other words, message `bid' means that offer contains a bundle which is proposed, `accept' means offer contains no bundle to propose,
|
---|
| 9 | * but an agreement with the deal (the received offer), and `end' again means that nothing to propose, and quitting the negotiation.
|
---|
[237] | 10 | *
|
---|
| 11 | *
|
---|
| 12 | */
|
---|
| 13 | public class Offer
|
---|
| 14 | {
|
---|
[270] | 15 | /**
|
---|
| 16 | * Message codes:
|
---|
| 17 | * (1) `bid' [body contains a bundle],
|
---|
| 18 | * (2) `accept' [agree with the deal (based on the rules); null body],
|
---|
| 19 | * (3) `end' [quitting the negotiation; null body]
|
---|
| 20 | */
|
---|
| 21 | protected MessageType type;
|
---|
| 22 | protected Bundle bundle;
|
---|
[237] | 23 |
|
---|
| 24 | public Offer()
|
---|
| 25 | {
|
---|
| 26 | }
|
---|
[270] | 27 |
|
---|
[237] | 28 | /**
|
---|
[270] | 29 | * Creates a bid
|
---|
[237] | 30 | */
|
---|
[270] | 31 | public Offer(Bundle b)
|
---|
| 32 | {
|
---|
| 33 | bundle = b;
|
---|
| 34 | type = MessageType.BID;
|
---|
[237] | 35 | }
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
[270] | 38 | * @return the proposal
|
---|
[237] | 39 | */
|
---|
[270] | 40 | public Bundle getBundle()
|
---|
| 41 | {
|
---|
| 42 | return bundle;
|
---|
[237] | 43 | }
|
---|
[270] | 44 |
|
---|
| 45 | @Override
|
---|
| 46 | public String toString()
|
---|
| 47 | {
|
---|
| 48 | if (type != MessageType.BID)
|
---|
| 49 | return type.toString();
|
---|
| 50 | else
|
---|
| 51 | return type.toString() + ": " + bundle.toString();
|
---|
[237] | 52 | }
|
---|
[270] | 53 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.