source: src/main/java/negotiator/onetomany/domain/test.java@ 236

Last change on this file since 236 was 236, checked in by Faria Nassiri Mofakham, 5 years ago

Bug in classes Chip, Stack and operations, Bundle and operations fixed; they work well. Old versions of aggregation operators and tests copied into an old file.

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