source: src/main/java/onetomany/BilateralNegotiation.java@ 257

Last change on this file since 257 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: 1.7 KB
RevLine 
[257]1/**
2 *
3 */
4package onetomany;
5
6
7import onetomany.bargainingchipsgame.Bundle;
8import onetomany.bargainingchipsgame.Chip;
9import onetomany.bargainingchipsgame.Stack;
10import onetomany.bargainingchipsgame.players.Agent;
11import onetomany.bargainingchipsgame.players.utilityfunction.UF_75pQtyOrNothing;
12import onetomany.bargainingchipsgame.players.utilityfunction.UF_FreeDisposal;
13
14/**
15 * @author Faria Nassiri-Mofakham
16 *
17 */
18public class BilateralNegotiation extends Thread{
19
20 private long number;
21 private Agent buyer;
22 private Agent seller;
23
24
25 public BilateralNegotiation(long number)
26 {
27 super();
28 }
29
30 public void run() {
31 // TODO Auto-generated method stub
32
33 Bundle a=new Bundle();
34 a.addStack(new Stack(new Chip("Blue", 4), 30));
35 a.addStack(new Stack(new Chip("Orange", 6), 20));
36
37 Runnable buyer = (Runnable) new Agent("Bob",a, new UF_75pQtyOrNothing(a), 10, null);
38 new Thread(buyer).start();
39 System.out.println(buyer);
40
41
42 Bundle b=new Bundle();
43 b.addStack(new Stack(new Chip("Red", 2), 50));
44 b.addStack(new Stack(new Chip("Green", 5), 70));
45
46 Runnable seller = (Runnable) new Agent("Sally",b, new UF_FreeDisposal(b), 20, null);
47 new Thread(seller).start();
48 System.out.println(seller);
49
50 super.run();
51
52 }
53
54 @Override
55 public String toString()
56 {
57 return this.getClass().getSimpleName()+"("+number+")\n"+buyer+"\n"+seller+"\n";
58 }
59 /**
60 * @param args
61 */
62 public static void main(String[] args)
63 {
64 // TODO Auto-generated method stub
65
66 // List<BilateralNegotiation> t;//= new ArrayList<BilateralNegotiation>();
67 //
68 //
69 for (long i=1; i<5; i++)
70 {
71 BilateralNegotiation t=new BilateralNegotiation(i);
72 System.out.println(t);
73 }
74 }
75
76}
Note: See TracBrowser for help on using the repository browser.