source: src/main/java/onetomany/bargainingchipsgame/interactions/Offer.java@ 257

Last change on this file since 257 was 253, checked in by Faria Nassiri Mofakham, 5 years ago

Commit #1 of:
+ negotiator.onetomany package refactored into onetomany package.
+ info created for all contained the packages.
+ current work defined under onetomany.bargainingchipsgame.
+ in this package, onetomany.bargainingchipsgame.players package includes packages for utility function, coordinator, negotiatior, and buyer and seller.
+ negotiator.onetomany package now contains nothing, can be deleted.
+ Interaction thread

File size: 1.6 KB
RevLine 
[237]1/**
2 * Offer class
3 */
[253]4package onetomany.bargainingchipsgame.interactions;
[237]5
[253]6import onetomany.bargainingchipsgame.Bundle;
[237]7
8/**
9 * An offer has two parts: (1) a bundle or null, (2) message code: `bid', `accept', `end'.
10 * When the code is 'bid', the first part is checked; for the two latter codes, the first part of the offer is null.
11 *
12 *
13 * @author Faria Nassiri-Mofakham
14 *
15 */
16public class Offer
17{
18
19 private Bundle bundle; //body of the offer, which is a bundle or null
20 private String message; //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]
21
22 public Offer()
23 {
24 setBundle(null);
25 setMessage("");
26 }
27
28 /**
29 * @return the proposal
30 */
31 public Bundle getBundle() {
32 return bundle;
33 }
34
35 /**
36 * @param proposal the proposal to set
37 */
38 public void setBundle(Bundle b) {
39 this.bundle = b;
40 }
41
42 /**
43 * @return the message
44 */
45 public String getMessage() {
46 return message;
47 }
48
49 /**
50 * @param message the message to set
51 */
52 public void setMessage(String m) {
53 this.message = m;
54 }
55
56 @Override
57 public String toString()
58 {
59 switch(message)
60 {
61 case "bid":
[253]62 return message+": "+bundle.toString();
[237]63 case "accept":
64 return "Accept!"; // might be completed during programming the protocol and agents //break;
65 case "end":
66 return "End!"; // might be completed during programming the protocol and agents //break;
67 default:
68 System.out.println(" Undefined message!");
69 return ""; //return null;
70 }
71 }
72
73}
Note: See TracBrowser for help on using the repository browser.