I have code for a Priority Queue Heap. This is for a simulation for airport. So
ID: 3679145 • Letter: I
Question
I have code for a Priority Queue Heap. This is for a simulation for airport.
So the set times are the arrival. I put them into a priority Queue. The Flight numbers into an array. The gates in a stack, user input (n) for the amount of gates being used. And lastly the departure is in a array using certain formula to make the percentage of the departure more or less than the 60 minutre mark (i.e being early or late to the airport)
And if all the gates are used print "airport full".
I am trying to get a better grasp on this. So how would I keep an update on the events all together? Since I have a queue, stack and a couple arrays.
2: LAX continuing to JFK 4: IAH continuing to MSP 11: SJC continuing to BOS 17: SFO continuing to ORD 28: TUL continuing to ONT 37: BNA continuing to SEA 49: HOS continuing to DEN 3: SMF continuing to RDU 9: ABQ continuing to ATL 14: PHX continuing to MIA 19 SLC continuing to AUS 33: DCA continuing to LAS 44: MAF continuing to AMA 55: ELP continuing to MEMExplanation / Answer
Hi ,
You could include a main function in your code to manage all the events all together. I have provided a java code example shown below. You can write a code like this so that you can manage the events.
NOTE: The below code is just an example and it doesn't apply to your simulation
/** Class PriorityQueueTest **/
public class PriorityQueueTest
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Priority Queue Test ");
System.out.println("Enter size of priority queue ");
PriorityQueue pq = new PriorityQueue(scan.nextInt() );
char ch;
/* Perform Priority Queue operations */
do
{
System.out.println(" Priority Queue Operations ");
System.out.println("1. insert");
System.out.println("2. remove");
System.out.println("3. check empty");
System.out.println("4. check full");
System.out.println("5. clear");
System.out.println("6. size");
int choice = scan.nextInt();
switch (choice)
{
case 1 :
System.out.println("Enter job name and priority");
pq.insert(scan.next(), scan.nextInt() );
break;
case 2 :
System.out.println(" Job removed "+ pq.remove());
break;
case 3 :
System.out.println(" Empty Status : "+ pq.isEmpty() );
break;
case 4 :
System.out.println(" Full Status : "+ pq.isFull() );
break;
case 5 :
System.out.println(" Priority Queue Cleared");
pq.clear();
break;
case 6 :
System.out.println(" Size = "+ pq.size() );
break;
default :
System.out.println("Wrong Entry ");
break;
}
System.out.println(" Do you want to continue (Type y or n) ");
ch = scan.next().charAt(0);
} while (ch == 'Y'|| ch == 'y');
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.