[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 |
|
---|
| 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 | } |
---|