Question
Objectives The objectives of this assignment are: Implement a Queue based on a doubly-linked lists To implement a List using Generics To implement a Java
Objectives The objectives of this assignment are: Implement a Queue based on a doubly-linked lists To implement a List using Generics To implement a Java iterator The Lab Java Files: List.java specifies the interface for a list using Generics and includes the printBackwards method. QueueInterface.java is well defined interface for a Queue ADT Part1. Implement a List based Queue class. You will write the LinkedQueue.java class that implements QueueInterface.java. Note that QueueInterface.java extends the Iterable interface., which means that you have to provide an iterator for it, similar to Assignment 1. The LinkedQueue implementation should be a doubly link list based one, based on the doubly link list you developed in Assignement 1 Part2. Using your LinkedQueue class. You will use the new LinkedQueue class to solve the following problem. Suppose that certain airport has one runway. Each airplane takes landingTime minutes to land and takeOffTime to take off, and that, on the average, planes arrive at random instants of time. (Delays make the assumption of randomness quite reasonable.) There are two types of queues: a queue of airplanes waiting to land, and a queue of airplanes waiting to takeoff. Because it is more expensive to keep a plane airborne than have one waiting on the ground, we assume that the airplanes in the landing queue have priority over those in the takeoff queue. Write a program to simulate this airports operation. You might assume a simulated clock that advances in five-minute interval. For each tic, generate two random numbers. If the first is less than landingRate, a landing arrival has occurred and is added to the landing queue; and if the second is less than takeOffRate, a takeoff arrival has occurred and is added to takeoff queue. In addition to simulating how queue get formed, and how planes get the authorization to land/takeoff, you program should calculate the average queue length and the average time that an airplane spends in a queue. You may also investigate the effect of varying arrival and departure rates to simulate the prime and slack times of day, or what happens if the amount of time to land and takeoff is increased or decreased. These variable parameters should be arguments to the program, and not hard coded.. You will need to use the LinkedQueue implementation you developed in part 1. Items to submit For any detail that was not provided, make a valid assumption, and document it in a text file you call Readme.txt, and that you submit with your code. You can defines as many files and functions as you want. However, the files listed in part 1 should be in their separate files. Submit the whole Eclipse project, containing all the classes as java files, as well as main function in its own separate java file. Do not forget to comment your code and submit a README. Include also any necessary additional files so that the code compile and runs properly.
QueueInterface.java
import java.util.NoSuchElementException; /** * * Generic interface for a FIFO queue. * * @paramThe type of Object that the queue will accept. * */ public interface QueueInterface extends Iterable { /** * This method is called to determine if the queue is empty. * * @return Returns true if the queue is empty, otherwise it returns false. */ public boolean isEmpty(); /** * This method is called to obtain the count of elements in the list. * * @return Returns the numbers of elements that are currently in the queue. */ public int size(); /** * * Adds the specified element into the stack if it is possible to do so immediately without * violating capacity restrictions, otherwise, throwing an IllegalStateException * if no space is currently available or NullPointerException if the specified element is null. * * @param e The element to add. * * @throws IllegalStateException If the element cannot be added at this time due to capacity restrictions. * @throws NullPointerException If the specified element being added is null. * */ public void enqueue(E e) throws IllegalStateException, NullPointerException; /** * * Retrieves, but does not remove, the head of this queue. * * @return The element at the head of the queue or null if the queue is empty. * */ public E peek(); /** * * Retrieves and removes the element at the head of this queue. * * @return The element at the head of the queue or null if the queue is empty. * */ public E dequeue(); /** * * Retrieves and removes the element at the specified index. * * @param index The index of the element to be removed. * * @return The element at the specified index. * * @throws NoSuchElementException If the specified index is invalid. * */ public E dequeue(int index) throws NoSuchElementException; /** * * Removes all elements from the queue. * */ public void removeAll(); }
List.java
public interface List{ /** * Adds item to the end of a list * * @param item */ public void addLast(T item); /** * Adds item to the start of a list * * @param item */ public void addFirst(T item); /** * Retrieves item from List * * @param position where 0 is the first position in the list * @return item - the item at the given position on the list * (or null if no item exists at that position) */ public T get (int position); /** * Prints list to screen */ public void print(); /** * Prints list backwards to screen */ public void printBackwards(); /** * Removes first item from List * * @param item * @return true if item was removed, false otherwise */ public boolean remove (T item); /** * Determines if the List is empty. * * @return True if the List is empty, False otherwise. */ public boolean isEmpty(); /** * Determines the number of items in the List * * @return int - The length of the list */ public int getLength(); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started