Пример #1
0
 /**
  * This method takes a movie from the top of the queue by the priority it was added and send it to
  * the home queue.
  *
  * @pre the waiting queue must not be empty
  * @post the correct movie will be dequeued from the waiting queue and enqueued in the home queue
  */
 public void sendMovieHomeByPriority() {
   Movie m = waitingQueue.dequeueByPriority();
   if (m == null) {
     return;
   }
   atHomeQueue.enqueue(m);
 }
Пример #2
0
 /**
  * This method is used for the UI to display the list of movies in priority order.
  *
  * @pre
  * @post the movies will be in the order of the priority the user queued them in, if two movies
  *     have the same priority then they appear in FIFO order
  * @return an array of {@link Movie} objects that are in priority order
  */
 public Movie[] displayWaitingMoviesByPriority() {
   @SuppressWarnings("unchecked")
   PriorityQueue<Movie> cloneOfP = (PriorityQueue<Movie>) DeepCopier.copy(waitingQueue);
   Movie[] movieList = new Movie[cloneOfP.getSize()];
   int i = 0;
   while (!cloneOfP.isEmpty()) {
     movieList[i] = cloneOfP.dequeueByPriority();
     i++;
   }
   return movieList;
 }