completed your work by the deadline. After the finance hold is lifted you must then submit the same work as normal on Blackboard, otherwise it will not be marked and you will get a fail for that part...

1 answer below »
see the brief


completed your work by the deadline. After the finance hold is lifted you must then submit the same work as normal on Blackboard, otherwise it will not be marked and you will get a fail for that part of the assessment. Airport Program - Coursework and In-Class Test You are to be assessed on how well you know Classes, objects, and data structures (queues). Most of the marks will come from your in-class test result. Concentrate on understanding the main code, and then getting additional program extras to work. Airport Program. 1. You are to implement three classes for this coursework that will be used to simulate passengers queuing at a boarding gate and boarding an airplane. The three classes and their important fields and methods are described in the Class diagram below. You may include additional fields and methods as required to complete the solution. Passenger. This class will contain the properties of a passenger relevant to our simulation. Fields - firstName:String, surname:String, secondsInQueue:int Methods - getters and setters (see class diagram). PassengerQueue. This class will represent the queue at the boarding gate. Fields queueArray: Array of Passenger, first:int, last:int, maxStayInQueue:int Methods: add(), remove(), display(), getMaxStay(), isEmpty(), isFull(). Airport: This is the main class that will drive the program. Fields: passengers: Array of Passenger, queue1: PassengerQueue Methods: main() and the other methods you implement from the menu. In a similar way to coursework 1, you should create a menu system in the main() method of your Airport class which allows the user to choose which operation they want the program to do. Each operation should be implemented as a separate method and the menu should allow the following operations: ‘A’ to add a passenger to the passengerQueue, and a ‘V’ to view the passengerQueue. ‘D’: Delete passenger from the passengerQueue, ‘S’: Store passengerQueue data into a plain text file, ‘L’: Load passengerQueue data back from the file into the passengerQueue ‘R’ : Run the simulation and produce report (see details below). Queue Details Create your own queue object in your program and write your own methods within the object to add to queue and take from queue. Every time a passenger is added to a passengerQueue it should prompt for passenger details, then use the queue objects method to add the passenger to the queue. When the user selects to view, the details of all passengers currently in the queue should be displayed. The queue should be based on an array and hold 20 Passengers. When the queue items reach the end of the array they should be added to the start of the array (circular queue). If the queue becomes full then an error message should be displayed. Note: Your solution should be a console application (not windows), and must be implemented by you based on lecture notes. ‘R’ – running the simulation details. You have been given a passenger list with passenger names (passengers.dat). The pseudocode for this portion is as follows: Read in the passenger file into the passengers array. Repeat until the passenger queue is empty Randomly generate a number of arrivers using 1 six sided die (as per your workshop). This will represent how many passengers join the queue. Add that number of passengers from the passengerArray into the passengerQueue. Randomly generate a processing delay using 3 six sided dice (as per your workshop). This will represent how many seconds it takes to check the boarding ticket and let the next passenger board the plane. Add the processing delay to each passenger already in the queue. Remove the next passenger from the queue. Gather waiting times and other statistics (length, max/min waiting time…) End repeat. Produce a report and output to the screen, and also output to a file called ‘report.dat’. The report should display the details of the passengers from passengerArray and then print a summary of the maximum length of the queue attained, the maximum waiting time, the minimum waiting time, and the average waiting time of all the passengers. For an additional challenge you can create two queues and have each passenger join the shortest queue. Compare the different summary statistics with the single queue implementation. (You can receive an extra 5% for this that may only be used to offset lost marks). Submission Instructions: Java Program code to be submitted as a single text file by the date shown above on Blackboard 4COSC005 ‘Submit Coursework’ link. For this submission you should copy and paste all classes into ONE long text file, type the filename at the top of each piece of pasted code, and at the very top of the text file type your name and your student id. Call this large saved file by your ID number (e.g. . w123456.txt ) and ensure it is saved as plain text. Do not change your code after it has been submitted. Tutorial in-class test. There will be a short in-class test in the theory tutorial session following the submission of the coursework. We need to know that you fully understand the code you use, and have not just stumbled on a solution, or copied it from elsewhere. For the test you will be assessed on how well you know classes, data structures, arrays, array manipulation code, and methods, so look at the examples in the notes as well as understanding your Airport program. Do not attempt to go to the wrong tutorial group without the tutor’s permission. If you miss the test there will be no other opportunity to redo the work in a later week unless you have approved mitigating circumstances. Sign-in on the class list during the test. Marking Criteria 80% of the marks will come from the in-class test result. If you score 4/15 or less in the in-class test then your code solution mark will be limited to a maximum of 50% as the test will have proved you did not really understand the code. 20% of the marks will come from your ‘Airport’ code solution. Code marking: 40% A basic solution with menu options A, V, D implemented as methods. +20% Options S and L working. +30% Simulation and report. Option R. +10% Demonstration and completed self-assessment form. Warning: All code must be done by yourself to ensure you can answer questions during the demonstration. You may be capped at 50% if you cannot explain the code. Pass grade: A basic code solution and 40% in the in-class test. Distinction grade (>=70%).
Answered Same DayApr 08, 2021

Answer To: completed your work by the deadline. After the finance hold is lifted you must then submit the same...

Aditi answered on Apr 09 2021
137 Votes
Solution/Airport.java
Solution/Airport.java
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;
import java.util.Scanner;
import java.util.l
ogging.Level;
import java.util.logging.Logger;
public class Airport {

    private Passenger passengers[];
    private PassengerQueue queue1;
    Scanner scan;
    public Airport() {
        passengers = new Passenger[20];
        queue1 = new PassengerQueue();
        scan = new Scanner(System.in);
    }

    public void addPassenger(){
        if(queue1.isFull()){
            System.out.println("Queue is full. No more passengers can be added.");
            return;
        }

        System.out.print("Enter first name: ");
        String fName = scan.nextLine();
        System.out.print("Enter surname: ");
        String sName = scan.nextLine();
        System.out.print("Enter number of seconds in queue: ");
        int sec = Integer.parseInt(scan.nextLine());
        queue1.add(new Passenger(fName, sName, sec));
        System.out.println("Passenger is added to the queue.");
    }

    public void display(){
        System.out.println("-----------PASSENGERS-----------");
        System.out.println("Name\t\tSeconds in queue");
        queue1.display();
    }

    public void deletePassenger(){
        if(queue1.isEmpty()){
            System.out.println("Queue is empty. Cannot delete any passenger");
            return;
        }
        Passenger pass = queue1.remove();
        System.out.println("Passenger deleted is: ");
        pass.display();
    }

    public void storePassengers(){
        if(queue1.isEmpty()){
            System.out.println("Queue is empty. No passengers to store in file.");
            return;
        }
        try {
            BufferedWriter writer = new BufferedWriter(new FileWriter("Passengers.txt"));
            writer.write(queue1.toString());
        } catch (IOException ex) {
            Logger.getLogger(Airport.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void loadPassengers(){
        try {
            Scanner file = new Scanner(new File("Passengers.txt"));
            while(file.hasNext()){
                String words[] = file.nextLine().split(" ");
                queue1.add(new Passenger(words[0], words[1], Integer.parseInt(words[2])));
            }
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Airport.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here