An airport has a runway for airplanes landing and taking off. When the runway is busy, airplanes wishing to take off or land have to wait. Landing airplanes get priority, and if the runway is available, it can be used. Implement a Java class, Airport.java, for this simulation, using two appropriate lists, one for the airplanes waiting to take off and one for those waiting to land. Note that the data structures you select for the two lists must be suitable for this purpose. For instance, the sooner an airplane comes for landing, the sooner it will land. Also, you must keep the record of all the airplanes that have already landed or taken off in one single list, to print out the activity log whenever asked, such that the sooner an airplane landed, the later it shows in the printout. To get a clear idea, please have a close look at the expected outputs of the execution of the tester class provided. The user enters the following commands: (The user entry has already been done in the tester class) • t flight-number (for taking off the airplane with the flight number flight-number) • l flight-number (for landing the airplane with the flight number flight-number) • n (for conducting the next possible landing or taking off operation) • p (for printing the current status of the two queues) • g (for printing the list of the airplanes already taken off or landed) • q (to quit the program) The first two commands, t and l, place the indicated flight in the take-off or landing queue, respectively. Command n will conduct the current take-off or landing, print the action (take-off or land) and the flightnumber, and enable the next one. Command p will print out the current content of the two queues. Command g will print out the list of all the airplanes that have already taken off or landed. Command q will quit the program. Provide required instance variables. Provide the following methods in this class: • The Airport class must have one default constructor to initialize the instance variables. • addTakeOff: It receives a flight-number as a String and updates the corresponding list. • addLanding: It receives a flight-number as a String and updates the corresponding list. • handleNextAction: It checks the landing and take-off lists and conducts one single operation as described above. It also returns a String showing the conducting operation, as you can see in the expected output. • waitingPlanes: It returns a String showing the list of all the waiting airplanes for landing/take-off, as you can see in the expected output. • log: It returns a String showing the list of all the operations already conducted, as you can see in the expected output. Note: The sooner an airplane landed/taken off, the later it must appear in the log. • Overloaded log: It receives the name of a text file as a String and writes the same output of the above log function into the text file instead of showing it on the screen. Note: The sooner an airplane lands/is taken off, the later it must appear in the log. The tester class, AirportTester.java, has been provided to help you with the development as well as executing and comparing the expected and actual outputs. The expected outputs of the AirportTester class using your code for Airport.java should be similar to the lines on the next page. Texts with green color are the user inputs. IN JAVA

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

An airport has a runway for airplanes landing and taking off. When the runway is busy, airplanes wishing to take off or land have to wait. Landing airplanes get priority, and if the runway is available, it can be used. Implement a Java class, Airport.java, for this simulation, using two appropriate lists, one for the airplanes waiting to take off and one for those waiting to land. Note that the data structures you select for the two lists must be suitable for this purpose. For instance, the sooner an airplane comes for landing, the sooner it will land. Also, you must keep the record of all the airplanes that have already landed or taken off in one single list, to print out the activity log whenever asked, such that the sooner an airplane landed, the later it shows in the printout. To get a clear idea, please have a close look at the expected outputs of the execution of the tester class provided. The user enters the following commands: (The user entry has already been done in the tester class) • t flight-number (for taking off the airplane with the flight number flight-number) • l flight-number (for landing the airplane with the flight number flight-number) • n (for conducting the next possible landing or taking off operation) • p (for printing the current status of the two queues) • g (for printing the list of the airplanes already taken off or landed) • q (to quit the program) The first two commands, t and l, place the indicated flight in the take-off or landing queue, respectively. Command n will conduct the current take-off or landing, print the action (take-off or land) and the flightnumber, and enable the next one. Command p will print out the current content of the two queues. Command g will print out the list of all the airplanes that have already taken off or landed. Command q will quit the program. Provide required instance variables. Provide the following methods in this class: • The Airport class must have one default constructor to initialize the instance variables. •  addTakeOff: It receives a flight-number as a String and updates the corresponding list. •  addLanding: It receives a flight-number as a String and updates the corresponding list. •  handleNextAction: It checks the landing and take-off lists and conducts one single operation as described above. It also returns a String showing the conducting operation, as you can see in the expected output. • waitingPlanes: It returns a String showing the list of all the waiting airplanes for landing/take-off, as you can see in the expected output. •  log: It returns a String showing the list of all the operations already conducted, as you can see in the expected output. Note: The sooner an airplane landed/taken off, the later it must appear in the log. • Overloaded log: It receives the name of a text file as a String and writes the same output of the above log function into the text file instead of showing it on the screen. Note: The sooner an airplane lands/is taken off, the later it must appear in the log. The tester class, AirportTester.java, has been provided to help you with the development as well as executing and comparing the expected and actual outputs. The expected outputs of the AirportTester class using your code for Airport.java should be similar to the lines on the next page. Texts with green color are the user inputs.

IN JAVA 

Runway Simulator Menu
> (1) add a plane for landing, followed by the flight symbol
> it) add a plane for take-off, followed by the flight symbol
> (n) perform next action
> (P) print the planes waiting for landing/take-off.
> (g) print the planes already landed/taken off to the screen
> (éj print the planes already landed/taken off to the output file
> (4) quit the simulation.
> g
No activity exists.
No plane is in the landing and take-off queues.
No plane is waiting to land or take off.
>t AA123
> 1 DA456
> 1 VA789
> n
Flight DA456 is landing.
> n
Flight VA789 is landing.
List of the landing/take-off activities
Flight VA789 landed.
Flight DAM56 landed.
Planes waiting for take-off
AA123
> t KT429
> 1 SP333
> n
Flight SP333 is landing.
> n
Flight AA123 is taking off.
> n
Flight KT429 is taking off.
List of the landing/take-off activities
Flight KT429 taken off.
Flight AM123 taken off.
Flight SP333 landed.
Flight VA799 landed.
Flight DM56 landed.
> f
Writing the airport log to the file...
Done.
No plane is in the landing and take-off queues.
Transcribed Image Text:Runway Simulator Menu > (1) add a plane for landing, followed by the flight symbol > it) add a plane for take-off, followed by the flight symbol > (n) perform next action > (P) print the planes waiting for landing/take-off. > (g) print the planes already landed/taken off to the screen > (éj print the planes already landed/taken off to the output file > (4) quit the simulation. > g No activity exists. No plane is in the landing and take-off queues. No plane is waiting to land or take off. >t AA123 > 1 DA456 > 1 VA789 > n Flight DA456 is landing. > n Flight VA789 is landing. List of the landing/take-off activities Flight VA789 landed. Flight DAM56 landed. Planes waiting for take-off AA123 > t KT429 > 1 SP333 > n Flight SP333 is landing. > n Flight AA123 is taking off. > n Flight KT429 is taking off. List of the landing/take-off activities Flight KT429 taken off. Flight AM123 taken off. Flight SP333 landed. Flight VA799 landed. Flight DM56 landed. > f Writing the airport log to the file... Done. No plane is in the landing and take-off queues.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education