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 | /**
|
---|
19 | * @param args
|
---|
20 | */
|
---|
21 | public static void main(String[] args)
|
---|
22 | {
|
---|
23 | // TODO
|
---|
24 | Chip chip1=new Chip("Pink", 5);
|
---|
25 | System.out.println("\nChip1: "+chip1);
|
---|
26 | Stack stack1=new Stack(chip1,12);
|
---|
27 | System.out.println("\nTEST1:::Stack1: "+stack1+", its price is "+stack1.getPrice());
|
---|
28 |
|
---|
29 | System.out.println("\n-----");
|
---|
30 |
|
---|
31 | Chip chip2=new Chip("Orange", 7);
|
---|
32 | System.out.println("\nChip2: "+chip2);
|
---|
33 | Stack stack2=new Stack(chip2,9);
|
---|
34 | System.out.println("\nTEST1:::Stack2: "+stack2+", its price is "+stack2.getPrice());
|
---|
35 |
|
---|
36 | System.out.println("\n-----");
|
---|
37 |
|
---|
38 | Chip c1=new Chip();
|
---|
39 | c1.setRandomColor();
|
---|
40 | double p1=100; double p2=1000;
|
---|
41 | c1.setRandomPrice(p1,p2);
|
---|
42 | System.out.println("With random defined color, and random price between "+p1+" and "+p2+", the Chip: "+c1);
|
---|
43 |
|
---|
44 | System.out.println("\n-----");
|
---|
45 |
|
---|
46 | Chip c2=new Chip();
|
---|
47 | c2.setColorRandomRGB();
|
---|
48 | c2.setRandomPrice(p1,p2);
|
---|
49 | System.out.println("With random RGB color, and random price between "+p1+" and "+p2+", the Chip: "+c2);
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 | System.out.println("\n-----");
|
---|
54 |
|
---|
55 | Bundle bundle1 = new Bundle();
|
---|
56 |
|
---|
57 | bundle1.addStack(stack1);
|
---|
58 | bundle1.addStack(stack2);
|
---|
59 |
|
---|
60 | System.out.println("\nTEST2:::Bundle1: "+bundle1);
|
---|
61 |
|
---|
62 |
|
---|
63 | //generating a bundle with stacks in random colors, random unit price, and random quantity
|
---|
64 | Bundle bundle2 = new Bundle();
|
---|
65 | for (int i=1; i<5;i++)
|
---|
66 | {
|
---|
67 | // int r=(int)(Math.random()*266; int g=(int)(Math.random()*266; int b=(int)(Math.random()*266;
|
---|
68 | // Color c=new Color((int)(Math.random()*255),(int)(Math.random()*255),(int)(Math.random()*255));
|
---|
69 | 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)));
|
---|
70 |
|
---|
71 | }
|
---|
72 |
|
---|
73 | System.out.println("\nTEST3:::Bundle2: "+bundle2);
|
---|
74 |
|
---|
75 |
|
---|
76 | Bundle bundle3= new Bundle();
|
---|
77 | bundle3.addStack(new Stack(new Chip("Red", 5), 17));
|
---|
78 | bundle3.addStack(new Stack(new Chip("Green", 7), 15));
|
---|
79 | bundle3.addStack(new Stack(new Chip("Blue", 10), 3));
|
---|
80 | bundle3.addStack(new Stack(new Chip("Pink", 2), 1));
|
---|
81 | bundle3.addStack(new Stack(new Chip("Orange", 1), 4));
|
---|
82 |
|
---|
83 | System.out.println("\nTEST4:::Bundle3: "+bundle3);
|
---|
84 |
|
---|
85 | Bundle bundle4= new Bundle();
|
---|
86 |
|
---|
87 | Bundle bundle5=null;
|
---|
88 |
|
---|
89 | System.out.println("\nBundle4: "+bundle4+"\nBundle5: "+bundle5);
|
---|
90 |
|
---|
91 | System.out.println("\n-----");
|
---|
92 |
|
---|
93 |
|
---|
94 | System.out.println("\n*TEST5::: Aggregating stack1: "+stack1+" into stack2: "+stack2+" results in "+stack2.aggregateWith(stack1));
|
---|
95 |
|
---|
96 |
|
---|
97 | System.out.println("\n-----");
|
---|
98 |
|
---|
99 | Stack s=null;
|
---|
100 |
|
---|
101 |
|
---|
102 |
|
---|
103 | System.out.println("\n*TEST6-01:::Stack1: "+stack1+" is aggregated with ``null Stack'' as follows:\n"+stack1.aggregateWith(s));
|
---|
104 |
|
---|
105 |
|
---|
106 | System.out.println("\n-----");
|
---|
107 |
|
---|
108 | Stack ss=new Stack(new Chip("Orange", 8),40);
|
---|
109 | // System.out.println("\n*TEST6-02:::Bundle1: "+bundle1+" is aggregated with Stack "+ss+" as follows:\n"+bundle1.aggregateWith(ss));
|
---|
110 |
|
---|
111 |
|
---|
112 |
|
---|
113 | // 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)));
|
---|
114 |
|
---|
115 |
|
---|
116 | Stack sss=new Stack(new Chip("Cyan", 5),16);
|
---|
117 |
|
---|
118 | // System.out.println("\n*TEST6-03:::Bundle1: "+bundle1+" is aggregated with Stack "+sss+" as follows:\n"+bundle1.aggregateWith(sss));
|
---|
119 |
|
---|
120 |
|
---|
121 | System.out.println("\n-----");
|
---|
122 |
|
---|
123 | Stack ssss=null;
|
---|
124 |
|
---|
125 | // System.out.println("\n*TEST7:::Bundle1: "+bundle1+" is aggregated with ``null Stack'' as follows:\n"+bundle1.aggregateWith(ssss));
|
---|
126 |
|
---|
127 |
|
---|
128 |
|
---|
129 | System.out.println("\n-----");
|
---|
130 |
|
---|
131 | System.out.println("\n*TEST8:::Bundle1: "+bundle1+" is aggregated with ``null bundle'' as follows:\n"+bundle1.aggregateWith(bundle5));
|
---|
132 |
|
---|
133 | System.out.println("\n-----");
|
---|
134 |
|
---|
135 | System.out.println("\n*TEST9:::Bundle1: "+bundle1+" is aggregated with Bundle3: "+bundle3+" as follows:\n"+ bundle1.aggregateWith(bundle3));
|
---|
136 |
|
---|
137 | System.out.println("\n-----");
|
---|
138 |
|
---|
139 | System.out.println("\n-----");
|
---|
140 |
|
---|
141 |
|
---|
142 |
|
---|
143 | Bundle b1=new Bundle();
|
---|
144 | b1.addStack(new Stack(new Chip("Red", 1), 10));
|
---|
145 | b1.addStack(new Stack(new Chip("Blue", 8), 30));
|
---|
146 | b1.addStack(new Stack(new Chip("Orange", 4), 30));
|
---|
147 | b1.addStack(new Stack(new Chip("Pink", 8), 80));
|
---|
148 |
|
---|
149 |
|
---|
150 |
|
---|
151 |
|
---|
152 | Bundle b2=new Bundle();
|
---|
153 | b2.addStack(new Stack(new Chip("Red", 3), 20));
|
---|
154 |
|
---|
155 | Bundle b3=new Bundle();
|
---|
156 | b3.addStack(new Stack(new Chip("Blue", 4), 30));
|
---|
157 | b3.addStack(new Stack(new Chip("Orange", 6), 20));
|
---|
158 |
|
---|
159 | Bundle b4=new Bundle();
|
---|
160 | b4.addStack(new Stack(new Chip("White", 4), 30));
|
---|
161 | b4.addStack(new Stack(new Chip("Yellow", 6), 20));
|
---|
162 |
|
---|
163 |
|
---|
164 | Bundle b5=new Bundle();
|
---|
165 | b5.addStack(new Stack(new Chip("Cyan", 7), 90));
|
---|
166 |
|
---|
167 |
|
---|
168 |
|
---|
169 | Bundle b6=new Bundle();
|
---|
170 | b6.addStack(new Stack(new Chip("Red", 9), 10));
|
---|
171 |
|
---|
172 |
|
---|
173 | Bundle bbb=new Bundle();
|
---|
174 | bbb=b3;
|
---|
175 | System.out.println("\n*TEST::: "+bbb);
|
---|
176 |
|
---|
177 | System.out.println("\n-----aggregateWith----");
|
---|
178 |
|
---|
179 |
|
---|
180 |
|
---|
181 |
|
---|
182 | System.out.println("\n-----BUNDLEaggregateWithBundle-----");
|
---|
183 |
|
---|
184 |
|
---|
185 | System.out.println("\n*TEST10-01::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b2.aggregateWith(bundle5));
|
---|
186 |
|
---|
187 |
|
---|
188 | System.out.println("\n*TEST10-02::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b1.aggregateWith(bundle5));
|
---|
189 |
|
---|
190 |
|
---|
191 | 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));
|
---|
192 |
|
---|
193 | 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));
|
---|
194 |
|
---|
195 | 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));
|
---|
196 |
|
---|
197 | 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));
|
---|
198 |
|
---|
199 |
|
---|
200 | 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));
|
---|
201 |
|
---|
202 |
|
---|
203 | 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));
|
---|
204 |
|
---|
205 | 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));
|
---|
206 |
|
---|
207 | // System.out.println("\n-----BUNDLEaggregateWith3Bundle-----");
|
---|
208 | //
|
---|
209 | //
|
---|
210 | //
|
---|
211 | // System.out.println("\n*TEST10-01::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b2.aggregateWith3(bundle5));
|
---|
212 | //
|
---|
213 | //
|
---|
214 | // System.out.println("\n*TEST10-02::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b1.aggregateWith3(bundle5));
|
---|
215 | //
|
---|
216 | //
|
---|
217 | // System.out.println("\n*TEST10-03::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b5+" as follows:\n"+ b2.aggregateWith3(b5));
|
---|
218 | //
|
---|
219 | // System.out.println("\n*TEST10-04::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b2.aggregateWith3(b3));
|
---|
220 | //
|
---|
221 | // System.out.println("\n*TEST10-05::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b6+" as follows:\n"+ b2.aggregateWith3(b6));
|
---|
222 | //
|
---|
223 | // System.out.println("\n*TEST10-06::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b1+" as follows:\n"+ b2.aggregateWith3(b1));
|
---|
224 | //
|
---|
225 | //
|
---|
226 | // System.out.println("\n*TEST10-07::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b1.aggregateWith3(b3));
|
---|
227 | //
|
---|
228 | //
|
---|
229 | // System.out.println("\n*TEST10-08::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with single stack B2: "+b2+" as follows:\n"+ b1.aggregateWith3(b2));
|
---|
230 | //
|
---|
231 | // System.out.println("\n*TEST10-09::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B2: "+b4+" as follows:\n"+ b1.aggregateWith3(b4));
|
---|
232 |
|
---|
233 |
|
---|
234 |
|
---|
235 | }
|
---|
236 |
|
---|
237 | }
|
---|