Line | |
---|
1 | package onetomany.bargainingchipsgame.interactions;
|
---|
2 |
|
---|
3 | import onetomany.bargainingchipsgame.Bundle;
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * An offer has two parts: (1) a bundle or null, (2) a message code: `bid', `accept', `end'.
|
---|
7 | * When the code is 'bid', the first part is checked; for the two latter codes, the first part of the offer is null.
|
---|
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.
|
---|
10 | *
|
---|
11 | *
|
---|
12 | */
|
---|
13 | public class Offer
|
---|
14 | {
|
---|
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;
|
---|
23 |
|
---|
24 | public Offer()
|
---|
25 | {
|
---|
26 | }
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Creates a bid
|
---|
30 | */
|
---|
31 | public Offer(Bundle b)
|
---|
32 | {
|
---|
33 | bundle = b;
|
---|
34 | type = MessageType.BID;
|
---|
35 | }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * @return the proposal
|
---|
39 | */
|
---|
40 | public Bundle getBundle()
|
---|
41 | {
|
---|
42 | return bundle;
|
---|
43 | }
|
---|
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();
|
---|
52 | }
|
---|
53 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.