Question: The completed Student Class /** * Student registration information * */ public class Student { final private String name ; final private boolean priority ;

The completed Student Class
/** * Student registration information * */ public class Student { final private String name; final private boolean priority; final private int credits; /** * Initializes the student * * @param name student name * @param priority does the student have priority registration? * @param credits completed credits */ public Student(String name, boolean priority, int credits) { this.name = name; this.priority = priority; this.credits = credits; } /** * Get the student's name * * @return student name */ public String getName() { return name; } /** * Get the student's priority status * * @return true if student has priority registration */ public boolean getPriority() { return priority; } /** * Get the student's completed credits * * @return student completed credits */ public int getCredits() { return credits; } @Override public String toString() { return String.format("%s (%b, %d)", name, priority, credits); } } The two methods : /** * Compares two students for registration priority: * - If both have priority, higher credits is greater * - If one has priority and the other doesn't, the priority is greater * - If neither have priority, higher credits is greater * * @param s1 student 1 * @param s2 student 2 * @return 0 if students are equal, 1 if s1 is greater, -1 if s2 is greater */ public static int studentCompare(Student s1, Student s2) { return 100; // replace with your code } /** * Orders students according to * registration priority * * @param students students to order * @return students sorted by greatest priority first (see studentCompare) */ public static Student[] classRegistration(Student[] students) { // Suggested algorithm: // 1. Create a priority queue that uses studentCompare, // at last in part, for its comparator // 2. Add all the students to the priority queue // 3. Remove all the students from the queue in order // into an array // 4. Return the array return new Student[] {}; } Test cases for the two methods:
final private static Student nF1 = new Student("nF1", false, 13);
final private static Student nF2 = new Student("nF2", false, 22);
final private static Student nF3 = new Student("nF3", false, 4);
final private static Student pF1 = new Student("pF1", true, 4);
final private static Student pF2 = new Student("pF2", true, 28);
final private static Student nS1 = new Student("nS1", false, 32);
final private static Student nS2 = new Student("nS2", false, 42);
final private static Student nS3 = new Student("nS3", false, 36);
final private static Student pS1 = new Student("pS1", true, 36);
final private static Student pS2 = new Student("pS2", true, 60);
final private static Student nSn1 = new Student("nSn1", false, 98);
final private static Student nSn2 = new Student("nSn2", false, 118);
final private static Student nSn3 = new Student("nSn3", false, 120);
final private static Student pSn1 = new Student("pSn1", true, 96);
final private static Student pSn2 = new Student("pSn2", true, 120); _testStudentCompare(nSn1, nSn1, 0);
_testStudentCompare(nSn3, nSn3, 0);
_testStudentCompare(pSn1, pSn1, 0);
_testStudentCompare(pSn2, pSn2, 0);
_testStudentCompare(nSn1, new Student("", nSn1.getPriority(), nSn1.getCredits()), 0);
_testStudentCompare(nF1, nF2, -1);
_testStudentCompare(nF2, nF1, 1);
_testStudentCompare(nF1, pF1, -1);
_testStudentCompare(nF1, pF2, -1);
_testStudentCompare(pF1, nF1, 1);
_testStudentCompare(pF2, nF1, 1);
_testStudentCompare(nF2, pF1, -1);
_testClassRegistration(new Student[] {}, new Student[] {});
_testClassRegistration(new Student[] {nF1}, new Student[] {nF1});
_testClassRegistration(new Student[] {pS2}, new Student[] {pS2});
_testClassRegistration(new Student[] {nJ3}, new Student[] {nJ3});
_testClassRegistration(new Student[] {pSn2}, new Student[] {pSn2});
_testClassRegistration(new Student[] {nF1, nF2}, new Student[] {nF2, nF1});
_testClassRegistration(new Student[] {nF2, nF1}, new Student[] {nF2, nF1});
_testClassRegistration(new Student[] {pF1, pF2}, new Student[] {pF2, pF1});
_testClassRegistration(new Student[] {pF2, pF1}, new Student[] {pF2, pF1});
_testClassRegistration(new Student[] {pS1, pS2}, new Student[] {pS2, pS1});
_testClassRegistration(new Student[] {pS2, pS1}, new Student[] {pS2, pS1});
Class Registration The first two methods have you use a PriorityQueue to order student objects (already written for you) for class registration. To begin implement the studentcompare method, which implements the registration priority policy (see the JavaDoc for details Once that is complete implement the classRegistration method, which inputs an array of Student objects, and then returns these same objects in the order in which they can register (i.e. greatest priority first). To obtain credit, you MUST use a PriorityQueue to order the Student objects in this method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
