[257] | 1 | /**
|
---|
| 2 | *
|
---|
| 3 | */
|
---|
| 4 | package onetomany;
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | import onetomany.bargainingchipsgame.Bundle;
|
---|
| 8 | import onetomany.bargainingchipsgame.Chip;
|
---|
| 9 | import onetomany.bargainingchipsgame.Stack;
|
---|
| 10 | import onetomany.bargainingchipsgame.players.Agent;
|
---|
| 11 | import onetomany.bargainingchipsgame.players.utilityfunction.UF_75pQtyOrNothing;
|
---|
| 12 | import onetomany.bargainingchipsgame.players.utilityfunction.UF_FreeDisposal;
|
---|
| 13 |
|
---|
| 14 | /**
|
---|
| 15 | * @author Faria Nassiri-Mofakham
|
---|
| 16 | *
|
---|
| 17 | */
|
---|
| 18 | public class BilateralNegotiation extends Thread{
|
---|
| 19 |
|
---|
[258] | 20 | // private long number;
|
---|
[257] | 21 | private Agent buyer;
|
---|
| 22 | private Agent seller;
|
---|
| 23 |
|
---|
| 24 |
|
---|
[258] | 25 | public BilateralNegotiation()
|
---|
[257] | 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();
|
---|
[258] | 39 | // System.out.println(buyer);
|
---|
[257] | 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();
|
---|
[258] | 48 | // System.out.println(seller);
|
---|
[257] | 49 |
|
---|
[258] | 50 | buyer.run();
|
---|
| 51 | seller.run();
|
---|
| 52 |
|
---|
| 53 | super.run();
|
---|
[257] | 54 |
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | @Override
|
---|
| 58 | public String toString()
|
---|
| 59 | {
|
---|
[258] | 60 | //return this.getClass().getSimpleName()+"("+number+")\n"+buyer+"\n"+seller+"\n";
|
---|
| 61 | return this.getClass().getSimpleName()+"\n"+buyer+"\n"+seller+"\n";
|
---|
| 62 |
|
---|
[257] | 63 | }
|
---|
| 64 | /**
|
---|
| 65 | * @param args
|
---|
| 66 | */
|
---|
| 67 | public static void main(String[] args)
|
---|
| 68 | {
|
---|
| 69 | // TODO Auto-generated method stub
|
---|
| 70 |
|
---|
[258] | 71 |
|
---|
| 72 | for (int i=1; i<5; i++)
|
---|
[257] | 73 | {
|
---|
[258] | 74 | BilateralNegotiation t=new BilateralNegotiation();
|
---|
| 75 | t.start();
|
---|
[257] | 76 | System.out.println(t);
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | } |
---|