source: src/main/java/onetomany/bargainingchipsgame/interactions/Thread.java@ 265

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

1) BilateralNegotiation which extends Thread added to onetomany. According to BCG protocol this creates two threads, one for a buyer and one for a seller (it now generates null agents). 2) An ActionListener added to close button in onetomany.etc.GUI.

File size: 3.0 KB
Line 
1/**
2 * Thread class
3 */
4package onetomany.bargainingchipsgame.interactions;
5
6import java.util.List;
7//import onetomany.etc; didn't work!
8
9import onetomany.bargainingchipsgame.Bundle;
10import onetomany.bargainingchipsgame.players.Agent;
11import onetomany.etc.OtherOperators;
12
13/**
14 * Thread is a for a bilateral negotiation.
15 * It is defined by introducing two parties and a list of actions exchanging between the two.
16 *
17 *
18 * @author Faria Nassiri-Mofakham
19 *
20 */
21public class Thread
22{
23 private List<Action> actions;
24 private Agent agent1;
25 private Agent agent2;
26 private long deadline; // is it required that a thread to have a deadline ?! When any party would send an end, so it will issue closing operation on the thread. So, we may only need to know when a thread were concluded. right?
27 private Boolean valid;
28 private Bundle outcome;
29
30
31
32 public Thread()
33 {
34 setActions(null);
35 setAgent1(null);
36 setAgent2(null);
37 setDeadline(0);
38 setValid(Boolean.FALSE);
39 setOutcome(null);
40 }
41
42 public Thread(Agent g1, Agent g2)
43 {
44 setActions(null);
45 setAgent1(g1);
46 setAgent2(g2);
47 setDeadline(Math.min(g1.getDeadline(),g2.getDeadline()));
48 setValid(Boolean.FALSE);
49 setOutcome(null);
50 }
51
52 public void addAction(Action c)
53 {
54 actions.add(c);
55 }
56
57 @Override
58 public String toString()
59 {
60 return " Bilateral thred "+this.getClass().getSimpleName()+"\n within deadline "+this.getDeadline()+"\n between "+this.getAgent1()+"\n and \n"+this.getAgent1()+"\n through the following actions \n "+this.getActions();
61 }
62
63 /**
64 * @ At the time of closing the thread, checks the sequence of actions to see if the thread is valid the valid to set
65 */
66 public void setValid(Boolean b)
67 {
68// for (Action c : this.actions)
69// if
70
71 this.valid = b;
72 }
73
74 /**
75 * @return the actions
76 */
77 public List<Action> getActions()
78 {
79 return actions;
80 }
81 /**
82 * @param actions the actions to set
83 */
84 public void setActions(List<Action> actions)
85 {
86 this.actions = actions;
87 }
88 /**
89 * @return the agent1
90 */
91 public Agent getAgent1()
92 {
93 return agent1;
94 }
95 /**
96 * @param agent1 the agent1 to set
97 */
98 public void setAgent1(Agent agent1)
99 {
100 this.agent1 = agent1;
101 }
102 /**
103 * @return the agent2
104 */
105 public Agent getAgent2() {
106 return agent2;
107 }
108 /**
109 * @param agent2 the agent2 to set
110 */
111 public void setAgent2(Agent agent2)
112 {
113 this.agent2 = agent2;
114 }
115
116
117 /**
118 * @return the deadline
119 */
120 public long getDeadline()
121 {
122 return deadline;
123 }
124
125 /**
126 * @param deadline the deadline to set
127 */
128 public void setDeadline(long deadline)
129 {
130 this.deadline = deadline;
131 }
132
133
134 /**
135 * @return the valid
136 */
137 public Boolean getValid()
138 {
139 return valid;
140 }
141
142
143 /**
144 * @return the outcome
145 */
146 public Bundle getOutcome() {
147 return outcome;
148 }
149
150 /**
151 * @param outcome the outcome to set
152 */
153 public void setOutcome(Bundle outcome)
154 {
155 this.outcome = outcome;
156 }
157}
Note: See TracBrowser for help on using the repository browser.