import java.util.Random;
import java.util.Vector;

public class Controller extends Thread{
	private final static String ARRIVAL   = "arrival";
	private final static String DEPARTURE = "departure";

	private Vector<Flight> arrivalsQueue;
	private Vector<Flight> departuresQueue;



	private class TS extends Thread{
		Vector<Flight> delayedQueue;
		

		
		TS(){
			delayedQueue = new Vector<Flight>();
		}



		TS(Vector<Flight> queue){
			delayedQueue = queue;
		}



		public void run(){
		/* Implement this method as specified in  
		 * http://www.math.unipd.it/~canlar/Lab5/Exercise1.pdf */				
		}
	}	


	
	Controller(){
		arrivalsQueue = new Vector<Flight>();
		departuresQueue = new Vector<Flight>();
	}



	public void addArrivals(Flight f){
		/* Implement this method as specified in  
		 * http://www.math.unipd.it/~canlar/Lab5/Exercise1.pdf */
	}



	public void addDepartures(Flight f){
		/* Implement this method as specified in  
		 * http://www.math.unipd.it/~canlar/Lab5/Exercise1.pdf */
	}

	

	private void manageArrivals(){
		/* Implement this method as specified in  
		 * http://www.math.unipd.it/~canlar/Lab5/Exercise1.pdf */
	}


	
	private void manageDepartures(){
		/* Implement this method as specified in  
		 * http://www.math.unipd.it/~canlar/Lab5/Exercise1.pdf */
	}



	private String getScheduledFlight(){
		int scheduledFlight;
		Random rand = new Random();

		/* The following randomly returns a 0 or 1 */
		scheduledFlight = rand.nextInt() % 2;
		if(scheduledFlight == 0)
			return ARRIVAL;
		if(scheduledFlight == 1)
			return DEPARTURE;
	
		
		/* This return will never be reached, but it is here 
		 * to make the JAVA compiler happy */
		return "";
	}



	public void run(){
		while(true){
			String scheduledFlight = getScheduledFlight();

			if(scheduledFlight.equals(ARRIVAL))
				manageArrivals();
			if(scheduledFlight.equals(DEPARTURE))
				manageDepartures();			
		}
	}

	
	
	public static void main(String[] argv){
		Controller cntrl = new Controller();

		/* Creating the traffic generating threads */
		GenerateArrivals generateArrivalsThread      = new GenerateArrivals(cntrl);
		GenerateDepartures generateDeparturesThread = new GenerateDepartures(cntrl);

		/* Starting all the threads needed for this program */
		generateArrivalsThread.start();
		generateDeparturesThread.start();	
		cntrl.start();
	}
}
