1 | /**
|
---|
2 | * Test class
|
---|
3 | */
|
---|
4 | package negotiator.onetomany.domain;
|
---|
5 |
|
---|
6 | import java.awt.Color;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * This class is for creating Chips, Stacks, and Bundles to test the operations
|
---|
10 | *
|
---|
11 | * @author Faria Nassiri-Mofakham
|
---|
12 | *
|
---|
13 | */
|
---|
14 |
|
---|
15 | public class test {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * @param args
|
---|
19 | */
|
---|
20 | public static void main(String[] args) {
|
---|
21 | // TODO
|
---|
22 | Chip chip1=new Chip("Pink", 5);
|
---|
23 | System.out.println("\nChip1: "+chip1);
|
---|
24 | Stack stack1=new Stack(chip1,12);
|
---|
25 | System.out.println("\nTEST1:::Stack1: "+stack1+", its price is "+stack1.getPrice());
|
---|
26 |
|
---|
27 | System.out.println("\n-----");
|
---|
28 |
|
---|
29 | Chip chip2=new Chip("Orange", 7);
|
---|
30 | System.out.println("\nChip2: "+chip2);
|
---|
31 | Stack stack2=new Stack(chip2,9);
|
---|
32 | System.out.println("\nTEST1:::Stack2: "+stack2+", its price is "+stack2.getPrice());
|
---|
33 |
|
---|
34 | System.out.println("\n-----");
|
---|
35 |
|
---|
36 |
|
---|
37 | Bundle bundle1 = new Bundle();
|
---|
38 |
|
---|
39 | bundle1.addStack(stack1);
|
---|
40 | bundle1.addStack(stack2);
|
---|
41 |
|
---|
42 | System.out.println("\nTEST2:::Bundle1: "+bundle1);
|
---|
43 |
|
---|
44 | //generating a bundle with stacks in random colors, random unit price, and random quantity
|
---|
45 | Bundle bundle2 = new Bundle();
|
---|
46 | for (int i=1; i<5;i++)
|
---|
47 | {
|
---|
48 | // int r=(int)(Math.random()*266; int g=(int)(Math.random()*266; int b=(int)(Math.random()*266;
|
---|
49 | // Color c=new Color((int)(Math.random()*255),(int)(Math.random()*255),(int)(Math.random()*255));
|
---|
50 | 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)));
|
---|
51 |
|
---|
52 | }
|
---|
53 |
|
---|
54 | System.out.println("\nTEST3:::Bundle2: "+bundle2);
|
---|
55 |
|
---|
56 |
|
---|
57 | Bundle bundle3= new Bundle();
|
---|
58 | bundle3.addStack(new Stack(new Chip("Red", 5), 17));
|
---|
59 | bundle3.addStack(new Stack(new Chip("Green", 7), 15));
|
---|
60 | bundle3.addStack(new Stack(new Chip("Blue", 10), 3));
|
---|
61 | bundle3.addStack(new Stack(new Chip("Pink", 2), 1));
|
---|
62 | bundle3.addStack(new Stack(new Chip("Orange", 1), 4));
|
---|
63 |
|
---|
64 | System.out.println("\nTEST4:::Bundle3: "+bundle3);
|
---|
65 |
|
---|
66 | Bundle bundle4= new Bundle();
|
---|
67 |
|
---|
68 | Bundle bundle5=null;
|
---|
69 |
|
---|
70 | System.out.println("\nBundle4: "+bundle4+"\nBundle5: "+bundle5);
|
---|
71 |
|
---|
72 | System.out.println("\n-----");
|
---|
73 |
|
---|
74 |
|
---|
75 | System.out.println("\n*TEST5::: Aggregating stack1: "+stack1+" with stack2: "+stack2+" results in "+stack2.aggregateWith(stack1));
|
---|
76 |
|
---|
77 |
|
---|
78 | System.out.println("\n-----");
|
---|
79 |
|
---|
80 | Stack s=null;
|
---|
81 |
|
---|
82 | 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)));
|
---|
83 | System.out.println("\n-----");
|
---|
84 |
|
---|
85 | System.out.println("\n*TEST7:::Bundle1: "+bundle1+" is aggregated with ``null Stack'' as follows:\n"+bundle1.aggregateWith(s));
|
---|
86 | System.out.println("\n-----");
|
---|
87 |
|
---|
88 | System.out.println("\n*TEST8:::Bundle1: "+bundle1+" is aggregated with ``null bundle'' as follows:\n"+bundle1.aggregateWith(bundle5));
|
---|
89 |
|
---|
90 | System.out.println("\n-----");
|
---|
91 |
|
---|
92 | System.out.println("\n*TEST9:::Bundle1: "+bundle1+" is aggregated with Bundle3: "+bundle3+" as follows:\n"+ bundle1.aggregateWith(bundle3));
|
---|
93 |
|
---|
94 | System.out.println("\n-----");
|
---|
95 |
|
---|
96 | //System.out.println("\n*TEST10:::***``Null Bundle5'': "+bundle5+" is aggregated with Stack: 40 x Chip(yellow, 8$) as follows:\n"+bundle5.aggregateWith(new Stack(new Chip("yellow", 8),40)));
|
---|
97 | System.out.println("\n-----");
|
---|
98 |
|
---|
99 | //System.out.println("\n*TEST11:::***``Null Bundle5'': "+bundle5+" is aggregated with Bundle1: "+bundle1+"as follows:\n"+bundle5.aggregateWith(bundle1));
|
---|
100 |
|
---|
101 | System.out.println("\n----- still problems with ``adding to null bundles'' in TEST10 and TEST11, even at returning back from internal function in TEST9.\nproblem is at adding a stack to a null bundle (see POINT1 reports, above, and so accordingly at POINT3). \nseems problem with creating/passing temporary bundle and stack variables AND it doesn't call the method from Stack class (POINT0)");
|
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|
105 | }
|
---|
106 |
|
---|
107 | }
|
---|