Question: The purpose of this program is to simulate the time behavior of airplanes arriving at an airport and waiting to land. Imagine that airplanes arrive

The purpose of this program is to simulate the time behavior of airplanes arriving at an airport and waiting to land. Imagine that airplanes arrive at random intervals with a limited quantity of fuel which determines their position in the holding pattern. Airlines with less fuel are given landing priority over airlines with more fuel. The airport can accept a landing every two minutes. Each plane belongs to one of eight airlines (United, Southwest, Northwest, Continental, American, Frontier, Alaska, or Lufthansa), has a flight number (1000-9999), and an amount of fuel left upon arrival (expressed in minutes as an integer from 1 to 20), and an arrival timeImplement this simulation by modifying LinkedQueue.java to turn it into a priority queue by creating and documenting a single new method called piorityEnqueue for enqueuing objects in priority order. Name the class PriorityQueue and submit it with the rest of your code.

Here is LinkedQueue.java:

public class LinkedQueue implements QueueInterface, java.io.Serializable { private Node firstNode; private Node lastNode; //******************************************************************** public LinkedQueue() { firstNode = null; lastNode = null; } //******************************************************************** public void enqueue(Object newEntry) { Node newNode = new Node(newEntry, null); if (isEmpty()) firstNode = newNode; else lastNode.setNextNode(newNode); lastNode = newNode; } //******************************************************************** public Object dequeue() { Object front = null; if (!isEmpty()) { front = firstNode.getData(); firstNode = firstNode.getNextNode(); if (firstNode == null) lastNode = null; } return front; } //******************************************************************** public Object getFront() { Object front = null; if (!isEmpty()) front = firstNode.getData(); return front; } //******************************************************************** public boolean isEmpty() { return firstNode == null; } //******************************************************************** public void clear() { firstNode = null; lastNode = null; } //******************************************************************** //******************************************************************** private class Node { private Object data; private Node next; private Node(Object dataPortion) { data = dataPortion; next = null; } private Node(Object dataPortion, Node nextNode) { data = dataPortion; next = nextNode; } private Object getData() { return data; } private void setData(Object newData) { data = newData; } private Node getNextNode() { return next; } private void setNextNode(Node nextNode) { next = nextNode; } }

Each time the user presses the ENTER key, one minute of simulation time will pass. If the user enters a P or p, time will pass but a new plane object will also be generated (i.e., corresponding to the random arrival of a plane). Entry of S or s shows the contents of the flight queue but no time passes. Entering X or x signals a desire to exit the routine. For each airplane object created you should randomly generate an airline, flight number, and remaining fuel quantity from the allowable range of parameters. You must also record the arrival time (measured in simulated minutes from the start of the simulation). The driver program should simulate the behavior of the queue as flights land and/or crash. Be sure to clearly indicate what happens as the simulation executes.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!