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

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

Commit #2:
Fixed errors

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;
11
12/**
13 * Thread is a for a bilateral negotiation.
14 * It is defined by introducing two parties and a list of actions exchanging between the two.
15 *
16 *
17 * @author Faria Nassiri-Mofakham
18 *
19 */
20public class Thread
21{
22 private List<Action> actions;
23 private Agent agent1;
24 private Agent agent2;
25 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?
26 private Boolean valid;
27 private Bundle outcome;
28
29
30
31 public Thread()
32 {
33 setActions(null);
34 setAgent1(null);
35 setAgent2(null);
36 setDeadline(0);
37 setValid(Boolean.FALSE);
38 setOutcome(null);
39 }
40
41 public Thread(Agent g1, Agent g2)
42 {
43 setActions(null);
44 setAgent1(g1);
45 setAgent2(g2);
46 setDeadline(min(g1.getDeadline(),g2.getDeadline()));
47 setValid(Boolean.FALSE);
48 setOutcome(null);
49 }
50
51 public void addAction(Action c)
52 {
53 actions.add(c);
54 }
55
56 @Override
57 public String toString()
58 {
59 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();
60 }
61
62 /**
63 * @ At the time of closing the thread, checks the sequence of actions to see if the thread is valid the valid to set
64 */
65 public void setValid(Boolean b)
66 {
67// for (Action c : this.actions)
68// if
69
70 this.valid = b;
71 }
72
73 /**
74 * @return the actions
75 */
76 public List<Action> getActions()
77 {
78 return actions;
79 }
80 /**
81 * @param actions the actions to set
82 */
83 public void setActions(List<Action> actions)
84 {
85 this.actions = actions;
86 }
87 /**
88 * @return the agent1
89 */
90 public Agent getAgent1()
91 {
92 return agent1;
93 }
94 /**
95 * @param agent1 the agent1 to set
96 */
97 public void setAgent1(Agent agent1)
98 {
99 this.agent1 = agent1;
100 }
101 /**
102 * @return the agent2
103 */
104 public Agent getAgent2() {
105 return agent2;
106 }
107 /**
108 * @param agent2 the agent2 to set
109 */
110 public void setAgent2(Agent agent2)
111 {
112 this.agent2 = agent2;
113 }
114
115
116 /**
117 * @return the deadline
118 */
119 public long getDeadline()
120 {
121 return deadline;
122 }
123
124 /**
125 * @param deadline the deadline to set
126 */
127 public void setDeadline(long deadline)
128 {
129 this.deadline = deadline;
130 }
131
132
133 /**
134 * @return the valid
135 */
136 public Boolean getValid()
137 {
138 return valid;
139 }
140
141
142 /**
143 * @return the outcome
144 */
145 public Bundle getOutcome() {
146 return outcome;
147 }
148
149 /**
150 * @param outcome the outcome to set
151 */
152 public void setOutcome(Bundle outcome)
153 {
154 this.outcome = outcome;
155 }
156
157
158 public long min(long op1, long op2)
159 {
160 if (op1>=op2)
161 return op2;
162 else
163 return op1;
164 }
165}
Note: See TracBrowser for help on using the repository browser.