source: src/main/java/negotiator/onetomany/interactions/Offer.java@ 244

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

(1) The info of package interaction briefly describes the protocol. (2) Offer class was created (including two parts: body, a bundle or null; message, `bid', 'accept', 'end')

File size: 1.6 KB
Line 
1/**
2 * Offer class
3 */
4package negotiator.onetomany.interactions;
5
6import negotiator.onetomany.domain.Bundle;
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":
62 return bundle.toString();
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.