************************************************ Class PriorityQueue You are to implement a method named filter, a method named insert and a method named remove to this Map class as described in the exam instructions. You may NOT alter the signature of these methods. You may add additional helper (private) methods if you choose, but you may NOT add additional public methods, nor may you change any methods that we have already defined. Name: Section: Date: andrew e-mail: *************************************************/ public class PriorityQueue { private Student[] values; private int numElements; /** * Constructor: allocates an array of length 1 * sets numElements to 0 * does not construct any individual elements */ public PriorityQueue() { values = new Student[1]; numElements = 0; } /************************************************ * TO THE STUDENT: IMPLEMENT THIS FILTER METHOD * ************************************************/ /** * Returns a PriorityQueue that has only those elements of this Map that are * the given type of student and have total tuition under the cutoff * @param studentType (String) - the type of student * @param cutoff (double) - the cutoff total tuition * @returns PriorityQueue - the new PriorityQueue */ // Write the filter method here /************************************************ * TO THE STUDENT: IMPLEMENT THIS INSERT METHOD * ************************************************/ /** * Inserts a value, newStudent, into the PriorityQueue as described in the * exam instructions. * * @param newStudent (Student) the new Student to be inserted into the PriorityQueue * * @returns void */ // Write the insert method here /************************************************ * TO THE STUDENT: IMPLEMENT THIS REMOVE METHOD * ************************************************/ /** * Removes a value with key, deleteKey, from the PriorityQueue as described in the * exam instructions. * * @param deleteKey (int) the key of the student ID to be removed from the PriorityQueue * * @returns void */ //Write the remove method here /************************************************ * TO THE STUDENT: * * DO NOT MODIFY ANY CODE BELOW THESE COMMENTS * ************************************************/ /** * Changes the array to have twice as many available cells as it has now. * All references in the original array are moved to the new array. * * @return void */ private void doubleLength() { Student[] newarray = new Student[values.length * 2]; for (int i = 0; i < numElements; i++) newarray[i] = values[i]; values = newarray; } /** * Returns a string representing the entire contents of the map * @return this map's string representation */ public String toString() { String result = " PriorityQueue[ " + "numElements=" + numElements + "/length=" + values.length; for (int i = 0; i < numElements; i++) result += "\n values["+i+"]= " + values[i].getName() + "(" + values[i].getID() + ") status= " + values[i].getStatus() + ", tuition= $" + values[i].getTotal(); result += "\n ]"; return result; } } //end of PriorityQueue