main 2.0

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
public static void main(String[] args) {
Random rand = new Random();
Worker w1 = new Worker("Бухгалтерия");
Worker w2 = new Worker("IT");
for(int i = 0; i < 20; i++) {
int type = Math.abs(rand.nextInt()%3);
int len = Math.abs(rand.nextInt()%10);
String value = "";
for(int j = 0; j < len; j++) {
value += Character.toString(new Character('a' + Math.abs(rand.nextInt()%26)));
}
switch(type) {
case 2:
System.out.println("w2 " + value);
w2.setJob(value);
break;
case 1:
System.out.println("w1 " + value);
w1.setJob(value);
break;
case 0:
System.out.println("w1 w2 " + value);
w1.setJob(value);
w2.setJob(value);
break;
}
}
for(int i = 0; i < 2; i++) {
System.out.println("W" + Integer.toString(i+1));
Worker item = i == 0 ? w1 : w2;
while (true) {
String job = item.getJob();
if(job == "Empty") {
break;
} else {
System.out.println(job);
}
}
}
}