Created
May 15, 2017 14:26
-
-
Save greut/a49c36a6060a90ba729f8966bb765d86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'application' | |
mainClassName = 'ch.hearc.airport.Main' | |
repositories { | |
mavenCentral() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.hearc.airport; | |
import java.util.HashMap; | |
import java.util.concurrent.ArrayBlockingQueue; | |
public class Main { | |
static String[] codePlane = { "3B147", "B3291", "6B239", "B1086", "780B4", | |
"32A64", "17A69", "2A431", "647B8", "349A8", "536B8", "9103A", | |
"9B210", "139A4", "96B01", "207B9", "830B6", "8435A", "7301B", | |
"1076B", "5281B", "8A521", "3B806", "B6842", "B6238", "7B816", | |
"A9437", "849A3", "60B18", "094B6", "4709B", "36A84", "085A3", | |
"0718B", "80B21", "0A369", "5290A", "370B4", "021A3", "84A02", | |
"052A6", "B6350", "630B5", "8B903", "1398B", "2693A", "902A6", | |
"51A20", "971A5", "A7891" }; | |
public static void main(String[] args) { | |
AirportFrame airportFrame = new AirportFrame(); | |
HashMap<QueueType, ArrayBlockingQueue<Avion>> queues = new HashMap<QueueType, ArrayBlockingQueue<Avion>>(); | |
for (QueueType type : QueueType.values()) { | |
queues.put(type, new ArrayBlockingQueue<Avion>(type.getSize())); | |
} | |
for (int i = 0; i < QueueType.AIR_ASCENSION.getSize(); i++) { | |
Avion avion = new Avion(airportFrame, codePlane[i], queues); | |
new Thread(avion).start(); | |
} | |
airportFrame.setVisible(true); | |
airportFrame.pack(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.hearc.airport; | |
public enum QueueType { | |
AIR_ASCENSION (20), | |
AIR_DESCENTE (20), // ! same as above, important ! | |
DÉCOLLAGE (2), | |
ATTERRISSAGE (2), | |
PARKING (4); | |
private final int size; | |
private QueueType(int size) { | |
this.size = size; | |
} | |
public int getSize() { | |
return size; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment