/** * Test class */ package onetomany; import java.awt.Color; import onetomany.bargainingchipsgame.Bundle; import onetomany.bargainingchipsgame.Chip; import onetomany.bargainingchipsgame.Stack; import onetomany.bargainingchipsgame.players.Agent; import onetomany.bargainingchipsgame.players.utilityfunction.UF_75pQtyOrNothing; import onetomany.bargainingchipsgame.players.utilityfunction.UF_AllOrNothing; import onetomany.bargainingchipsgame.players.utilityfunction.UF_FreeDisposal; import onetomany.bargainingchipsgame.players.utilityfunction.UF_IWant3Red; import onetomany.bargainingchipsgame.players.utilityfunction.UF_IWantColorAndQuantity; import onetomany.bargainingchipsgame.players.utilityfunction.UF_Nice; import onetomany.bargainingchipsgame.players.utilityfunction.UF_Silly; import onetomany.bargainingchipsgame.players.utilityfunction.UF_prcntQTYandprcntPrice; import onetomany.bargainingchipsgame.players.utilityfunction.Utility_Function; /** * This class is for creating Chips, Stacks, and Bundles to test the operations * * @author Faria Nassiri-Mofakham * */ public class test { /** * @param args */ public static void main(String[] args) { // TODO Chip chip1=new Chip("Pink", 5); System.out.println("\nChip1: "+chip1); Stack stack1=new Stack(chip1,12); System.out.println("\nTEST1:::Stack1: "+stack1+", its price is "+stack1.getPrice()); System.out.println("\n-----"); Chip chip2=new Chip("Orange", 7); System.out.println("\nChip2: "+chip2); Stack stack2=new Stack(chip2,9); System.out.println("\nTEST1:::Stack2: "+stack2+", its price is "+stack2.getPrice()); System.out.println("\n-----"); Chip c1=new Chip(); c1.setRandomColor(); double p1=100; double p2=1000; c1.setRandomPrice(p1,p2); System.out.println("With random defined color, and random price between "+p1+" and "+p2+", the Chip: "+c1); System.out.println("\n-----"); Chip c2=new Chip(); c2.setColorRandomRGB(); c2.setRandomPrice(p1,p2); System.out.println("With random RGB color, and random price between "+p1+" and "+p2+", the Chip: "+c2); System.out.println("\n-----"); Bundle bundle1 = new Bundle(); bundle1.addStack(stack1); bundle1.addStack(stack2); System.out.println("\nTEST2:::Bundle1: "+bundle1); //generating a bundle with stacks in random colors, random unit price, and random quantity Bundle bundle2 = new Bundle(); for (int i=1; i<5;i++) { // int r=(int)(Math.random()*266; int g=(int)(Math.random()*266; int b=(int)(Math.random()*266; // Color c=new Color((int)(Math.random()*255),(int)(Math.random()*255),(int)(Math.random()*255)); bundle2.addStack(new Stack(new Chip(new Color((int)(Math.random()*255+1),(int)(Math.random()*255+1),(int)(Math.random()*255+1)).toString(), (double)(Math.random()*20+1)), (int)(Math.random()*10+1))); } System.out.println("\nTEST3:::Bundle2: "+bundle2); Bundle bundle3= new Bundle(); bundle3.addStack(new Stack(new Chip("Red", 5), 17)); bundle3.addStack(new Stack(new Chip("Green", 7), 15)); bundle3.addStack(new Stack(new Chip("Blue", 10), 3)); bundle3.addStack(new Stack(new Chip("Pink", 2), 1)); bundle3.addStack(new Stack(new Chip("Orange", 1), 4)); System.out.println("\nTEST4:::Bundle3: "+bundle3); Bundle bundle4= new Bundle(); Bundle bundle5=null; System.out.println("\nBundle4: "+bundle4+"\nBundle5: "+bundle5); System.out.println("\n-----"); System.out.println("\n*TEST5::: Aggregating stack1: "+stack1+" into stack2: "+stack2+" results in "+stack2.aggregateWith(stack1)); System.out.println("\n-----"); Stack s=null; System.out.println("\n*TEST6-01:::Stack1: "+stack1+" is aggregated with ``null Stack'' as follows:\n"+stack1.aggregateWith(s)); System.out.println("\n-----"); Stack ss=new Stack(new Chip("Orange", 8),40); // System.out.println("\n*TEST6-02:::Bundle1: "+bundle1+" is aggregated with Stack "+ss+" as follows:\n"+bundle1.aggregateWith(ss)); // System.out.println("\n*TEST6:::Bundle1: "+bundle1+" is aggregated with Stack: 40 x Chip(Yellow, 8$) as follows:\n"+bundle1.aggregateWith(new Stack(new Chip("Yellow", 8),40))); Stack sss=new Stack(new Chip("Cyan", 5),16); // System.out.println("\n*TEST6-03:::Bundle1: "+bundle1+" is aggregated with Stack "+sss+" as follows:\n"+bundle1.aggregateWith(sss)); System.out.println("\n-----"); Stack ssss=null; // System.out.println("\n*TEST7:::Bundle1: "+bundle1+" is aggregated with ``null Stack'' as follows:\n"+bundle1.aggregateWith(ssss)); System.out.println("\n-----"); System.out.println("\n*TEST8:::Bundle1: "+bundle1+" is aggregated with ``null bundle'' as follows:\n"+bundle1.aggregateWith(bundle5)); System.out.println("\n-----"); System.out.println("\n*TEST9:::Bundle1: "+bundle1+" is aggregated with Bundle3: "+bundle3+" as follows:\n"+ bundle1.aggregateWith(bundle3)); System.out.println("\n-----"); System.out.println("\n-----"); Bundle b1=new Bundle(); b1.addStack(new Stack(new Chip("Red", 1), 10)); b1.addStack(new Stack(new Chip("Blue", 8), 30)); b1.addStack(new Stack(new Chip("Orange", 4), 30)); b1.addStack(new Stack(new Chip("Pink", 8), 80)); Bundle b2=new Bundle(); b2.addStack(new Stack(new Chip("Red", 3), 20)); Bundle b3=new Bundle(); b3.addStack(new Stack(new Chip("Blue", 4), 30)); b3.addStack(new Stack(new Chip("Orange", 6), 20)); Bundle b4=new Bundle(); b4.addStack(new Stack(new Chip("White", 4), 30)); b4.addStack(new Stack(new Chip("Yellow", 6), 20)); Bundle b5=new Bundle(); b5.addStack(new Stack(new Chip("Cyan", 7), 90)); Bundle b6=new Bundle(); b6.addStack(new Stack(new Chip("Red", 9), 10)); Bundle bbb=new Bundle(); bbb=b3; System.out.println("\n*TEST::: "+bbb); System.out.println("\n-----aggregateWith----"); System.out.println("\n-----BUNDLEaggregateWithBundle-----"); System.out.println("\n*TEST10-01::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b2.aggregateWith(bundle5)); System.out.println("\n*TEST10-02::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b1.aggregateWith(bundle5)); System.out.println("\n*TEST10-03::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b5+" as follows:\n"+ b2.aggregateWith(b5)); System.out.println("\n*TEST10-04::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b2.aggregateWith(b3)); System.out.println("\n*TEST10-05::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b6+" as follows:\n"+ b2.aggregateWith(b6)); System.out.println("\n*TEST10-06::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b1+" as follows:\n"+ b2.aggregateWith(b1)); System.out.println("\n*TEST10-07::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b1.aggregateWith(b3)); System.out.println("\n*TEST10-08::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with single stack B2: "+b2+" as follows:\n"+ b1.aggregateWith(b2)); System.out.println("\n*TEST10-09::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B2: "+b4+" as follows:\n"+ b1.aggregateWith(b4)); System.out.println("\n-----BUNDLEaggregateWith333Bundle-----"); System.out.println("\n*TEST10-01::: Without shared colors ::: single stack B2: "+b2+" is aggregated333 with ``null'' bundle5 as follows:\n"+ b2.aggregateWith333(bundle5)); System.out.println("\n*TEST10-02::: Without shared colors ::: multi stack B1: "+b1+" is aggregated333 with ``null'' bundle5 as follows:\n"+ b1.aggregateWith333(bundle5)); System.out.println("\n*TEST10-03::: Without shared colors ::: single stack B2: "+b2+" is aggregated333 with single stack B5: "+b5+" as follows:\n"+ b2.aggregateWith333(b5)); System.out.println("\n*TEST10-04::: Without shared colors ::: single stack B2: "+b2+" is aggregated333 with multi stack B3: "+b3+" as follows:\n"+ b2.aggregateWith333(b3)); System.out.println("\n*TEST10-05::: With shared colors ::: single stack B2: "+b2+" is aggregated333 with single stack B5: "+b6+" as follows:\n"+ b2.aggregateWith333(b6)); System.out.println("\n*TEST10-06::: With shared colors ::: single stack B2: "+b2+" is aggregated333 with multi stack B3: "+b1+" as follows:\n"+ b2.aggregateWith333(b1)); System.out.println("\n*TEST10-07::: With shared colors ::: multi stack B1: "+b1+" is aggregated333 with multi stack B3: "+b3+" as follows:\n"+ b1.aggregateWith333(b3)); System.out.println("\n*TEST10-08::: With shared colors ::: multi stack B1: "+b1+" is aggregated333 with single stack B2: "+b2+" as follows:\n"+ b1.aggregateWith333(b2)); System.out.println("\n*TEST10-09::: Without shared colors ::: multi stack B1: "+b1+" is aggregated333 with multi stack B2: "+b4+" as follows:\n"+ b1.aggregateWith333(b4)); System.out.println("\n-----TEST11: Agent creations -----"); Utility_Function u1=new UF_IWant3Red(); Agent belinda = new Agent();//bundle3, u, 10, null); belinda.setName("Belinda"); belinda.setWishlist(bundle3); belinda.setUtility(u1); belinda.setDeadline(10); System.out.println("\n"+belinda+"\nTEST11-01* utility of aggregated bundle TEST10-09 "+b1.aggregateWith(b4)+"\nfor "+belinda.getName()+" is: "+belinda.getUtility().getUtility(b1.aggregateWith(b4))); Utility_Function u2=new UF_Nice(); Agent bella = new Agent();//bundle3, u, 10, null); bella.setName("Bella"); bella.setWishlist(bundle3); bella.setUtility(u2); bella.setDeadline(100); System.out.println("\n"+bella+"\nTEST11-02* utility of aggregated bundle TEST10-09 "+b1.aggregateWith(b4)+"\nfor "+bella.getName()+" is: "+bella.getUtility().getUtility(b1.aggregateWith(b4))); Utility_Function u4=new UF_AllOrNothing(bundle3); Agent sam = new Agent(); sam.setName("Sam"); sam.setWishlist(bundle3); sam.setUtility(u4); sam.setDeadline(1000); System.out.println("\n"+sam+"\nTEST11-04* utility of bundle3 "+bundle3+"\nfor "+sam.getName()+" is: "+sam.getUtility().getUtility(bundle3)); Bundle a=new Bundle(); a.addStack(new Stack(new Chip("Blue", 4), 30)); a.addStack(new Stack(new Chip("Orange", 6), 20)); Bundle aa=new Bundle(); aa.addStack(new Stack(new Chip("Orange", 6), 20)); aa.addStack(new Stack(new Chip("Blue", 4), 30)); Utility_Function u5=new UF_AllOrNothing(a); Agent simon = new Agent(); simon.setName("Simon"); simon.setWishlist(a); simon.setUtility(u5); simon.setDeadline(1000); System.out.println("\n"+simon+"\nTEST11-05* utility of bundle aa "+aa+"\nfor "+simon.getName()+" is: "+simon.getUtility().getUtility(aa)); Bundle aaa=new Bundle(); aaa.addStack(new Stack(new Chip("Orange", 6), 20)); aaa.addStack(new Stack(new Chip("Blue", 4), 30)); aaa.addStack(new Stack(new Chip("White", 4), 30)); Utility_Function u6=new UF_FreeDisposal(aaa); Agent bethy = new Agent(); bethy.setName("Bethy"); bethy.setWishlist(aaa); bethy.setUtility(u6); bethy.setDeadline(1000); System.out.println("\n"+bethy+"\nTEST11-06* utility of bundle aa "+aa+"\nfor "+bethy.getName()+" is: "+bethy.getUtility().getUtility(aa)); System.out.println("\n"+bethy+"\nTEST11-07* utility of bundle aaa "+aaa+"\nfor "+bethy.getName()+" is: "+bethy.getUtility().getUtility(aaa)); Bundle aaaa=new Bundle(); aaaa.addStack(new Stack(new Chip("Orange", 6), 20)); System.out.println("\n"+bethy+"\nTEST11-08* utility of bundle aaaa "+aaaa+"\nfor "+bethy.getName()+" is: "+bethy.getUtility().getUtility(aaaa)); Utility_Function u8=new UF_Silly(); Agent sterling = new Agent(); sterling.setName("Sterling"); sterling.setWishlist(a); sterling.setUtility(u8); sterling.setDeadline(10); System.out.println("\n"+sterling+"\nTEST11-09* utility of bundle a "+a+"\nfor "+sterling.getName()+" is: "+sterling.getUtility().getUtility(a)); System.out.println("\n"+sterling+"\nTEST11-10* utility of bundle aaaa "+aaaa+"\nfor "+sterling.getName()+" is: "+sterling.getUtility().getUtility(aaaa)); System.out.println("\n"+sterling+"\nTEST11-11* utility of bundle aaa "+aaa+"\nfor "+sterling.getName()+" is: "+sterling.getUtility().getUtility(aaa)); String c="Blue"; int q=30; Bundle w=new Bundle(); w.addStack(new Stack(new Chip(c,10),q)); Utility_Function u9=new UF_IWantColorAndQuantity(c, q); Agent sandra = new Agent(); sandra.setName("Sandra"); sandra.setWishlist(w); // there should be a better way to bring those parameters for making the wishlist at time of calling the utility function sandra.setUtility(u9); sandra.setDeadline(10); System.out.println("\n"+sandra+"\nTEST11-09* utility of bundle a "+a+"\nfor "+sandra.getName()+" is: "+sandra.getUtility().getUtility(a)); System.out.println("\n"+sandra+"\nTEST11-10* utility of bundle aaaa "+aaaa+"\nfor "+sandra.getName()+" is: "+sandra.getUtility().getUtility(aaaa)); System.out.println("\n"+sandra+"\nTEST11-11* utility of bundle aaa "+aaa+"\nfor "+sandra.getName()+" is: "+sandra.getUtility().getUtility(aaa)); System.out.println("\n========================IT IS UF_prcntQTYandprcntPrice========================="); Utility_Function u3=new UF_prcntQTYandprcntPrice(b3,0.5,0.5); Agent bob = new Agent(); bob.setName("Bob"); bob.setWishlist(b3); bob.setUtility(u3); bob.setDeadline(100); System.out.println("\n"+bob+"\nTEST11-03* utility of b1 "+b3+"\nfor "+bob.getName()+" is: "+bob.getUtility().getUtility(b3)+"\n"+bob.getWishlist().getPrice()+"\n"+b3.getPrice()); System.out.println("\n"+bob+"\nTEST11-033* utility of b1 "+b1+"\nfor "+bob.getName()+" is: "+bob.getUtility().getUtility(b1)+"\n"+bob.getWishlist().getPrice()+"\n"+b1.getPrice()); System.out.println("\n"+bob+"\nTEST11-0333* utility of b1 "+aaa+"\nfor "+bob.getName()+" is: "+bob.getUtility().getUtility(aaa)+"\n"+bob.getWishlist().getPrice()+"\n"+aaa.getPrice()); Utility_Function u33=new UF_prcntQTYandprcntPrice(b3,0.1,0.1); Agent bob33 = new Agent(); bob33.setName("Bob33"); bob33.setWishlist(b3); bob33.setUtility(u33); bob33.setDeadline(100); System.out.println("\n"+bob33+"\nTEST11-03* utility of b1 "+b3+"\nfor "+bob33.getName()+" is: "+bob33.getUtility().getUtility(b3)+"\n"+bob33.getWishlist().getPrice()+"\n"+b3.getPrice()); System.out.println("\n"+bob33+"\nTEST11-033* utility of b1 "+b1+"\nfor "+bob33.getName()+" is: "+bob33.getUtility().getUtility(b1)+"\n"+bob33.getWishlist().getPrice()+"\n"+b1.getPrice()); System.out.println("\n"+bob33+"\nTEST11-0333* utility of b1 "+aaa+"\nfor "+bob33.getName()+" is: "+bob33.getUtility().getUtility(aaa)+"\n"+bob33.getWishlist().getPrice()+"\n"+aaa.getPrice()); Utility_Function u333=new UF_prcntQTYandprcntPrice(b3,0.8,0.8); Agent bob333 = new Agent(); bob333.setName("Bob333"); bob333.setWishlist(b3); bob333.setUtility(u333); bob333.setDeadline(100); System.out.println("\n"+bob333+"\nTEST11-03* utility of b1 "+b3+"\nfor "+bob333.getName()+" is: "+bob333.getUtility().getUtility(b3)+"\n"+bob333.getWishlist().getPrice()+"\n"+b3.getPrice()); System.out.println("\n"+bob333+"\nTEST11-033* utility of b1 "+b1+"\nfor "+bob333.getName()+" is: "+bob333.getUtility().getUtility(b1)+"\n"+bob333.getWishlist().getPrice()+"\n"+b1.getPrice()); System.out.println("\n"+bob333+"\nTEST11-0333* utility of b1 "+aaa+"\nfor "+bob333.getName()+" is: "+bob333.getUtility().getUtility(aaa)+"\n"+bob333.getWishlist().getPrice()+"\n"+aaa.getPrice()); Utility_Function u7=new UF_75pQtyOrNothing(a); Agent barbara = new Agent(); barbara.setName("Barbara"); barbara.setWishlist(a); barbara.setUtility(u7); barbara.setDeadline(10); System.out.println("\n"+barbara+"\nTEST11-09* utility of bundle a "+a+"\nfor "+barbara.getName()+" is: "+barbara.getUtility().getUtility(a)+" size of wishlist "+barbara.getWishlist().size()+ " "+(double)barbara.getWishlist().size()*0.75); System.out.println("\n"+barbara+"\nTEST11-10* utility of bundle aaaa "+aaaa+"\nfor "+barbara.getName()+" is: "+barbara.getUtility().getUtility(aaaa)); System.out.println("\n"+barbara+"\nTEST11-11* utility of bundle aaa "+aaa+"\nfor "+barbara.getName()+" is: "+barbara.getUtility().getUtility(aaa)); } }