-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMainVersioneBase.java
56 lines (43 loc) · 1.35 KB
/
MainVersioneBase.java
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
50
51
52
53
54
55
56
/*
*
* made by:
* Confalonieri Riccardo
* github.com/rconfa
*
*/
package carParks;
public class MainVersioneBase {
public static void main(String[] args){
Posto[] posti = new Posto[10];
Parcheggiatore[] parcheggiatori = new Parcheggiatore[8];
Parcheggio p1 = new Parcheggio("parcheggio1", "via Milano 60", posti, parcheggiatori);
Automobile[] auto = new Automobile[12];
Automobilista[] automobilisti = new Automobilista[12];
for (int i = 0; i < posti.length; i++)
posti[i] = new Posto(i, false);
for (int i = 0; i < parcheggiatori.length; i++)
parcheggiatori[i] = new Parcheggiatore(i, false);
for (int i = 0; i < auto.length; i++)
auto[i] = new Automobile("targa" + i, "Fiat", "Punto", i * 30);
for (int i = 0; i < automobilisti.length; i++)
automobilisti[i] = new Automobilista("Name" + i, "Surname" + i, "CodFis" + i, auto[i], p1);
for (Automobilista a : automobilisti) {
a.start();
}
try {
Thread.sleep(10000);
for (Automobilista a : automobilisti)
a.stopExecution();
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
for (Automobilista a : automobilisti)
a.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Main terminated");
}
}