Introduction

In this lab you will modify existing code to implement a priority queue based on an underlying linked list. The priority queue will stores instances of a class Student (download Student.java ).

Instructions

(From LaFore, task 5.1 p. 248) Implement a priority queue (class name PriorityQ) based on the code in sortedList.java. PriorityQ should store instances of Student, with priority being based on credits earned (more credits == higher priority). Write a tester class called PriorityQApp that demonstrates the functioning of PriorityQ.

  1. Review the code for priorityQ.java (Listing 4.6 p. 147); understand the functionality of a priority queue.
  2. Review the code for sortedList.java (Listing 5.6 p. 215); understand the implementation of a sorted list. You will base your code on sortedList.java. Note that sortedList.java is written to store instances of the primitive type long; you will instead be storing instances of the class Student.

Class Student PriorityQueue

public class PriorityQueue {

   public void insert(Student s);
   public Student remove();
   public Student peek();
   public boolean isEmpty();
   public void display();
}

 

Class PriorityQApp

  1. whenever the queue changes, show the current queue in order or report "The queue is empty"
  2. successful add() should report that the individual has been added
  3. successful remove() should display the Student and report that s/he has been removed
  4. successful remove() should ALSO report whenever the last individual has been removed

When run, PriorityQApp should create an instance of PriorityQ and then carry out a variety of actions (insert, remove, display) demonstrating the functionality of the program. You can use invented data for this -- you needn't query the user to enter information.

Lab Report

Include a lab report with your submission, describing your development process, any design decisions made along the way, format/method of input & output, and limitations on your code.

Due date & submission

  1. LAB 05 is due by 5:00 PM on FRi 12 MAR 2010.
  2. Submit your assignment as a single .zip archive file titled LAB51_lastname.zip. It should include working, documented java code as well as the lab report.
  3. Submit via sakai.messiah.edu | COSC282 | Assignments | Lab05.
Copyright © 1999-2008| Gene Rohrbaugh | Privacy Statement