import structure.*; import com.mw.io.*; import java.io.*; // This program is a solution to lab 10 using the Vector as the // underlying data structure -- it works, but it's not very fast. public class Student implements Comparable { public int student_id; public int student_class; public int numDesired; // no. of courses on first line of reg. card public int numChoices; // total no. of courses listed on all lines public Vector student_choices; // course_names of all courses listed public int numEnrolled; // no. of courses in which student is enrolled public Student() { student_id = 0; student_class = 0; numDesired = 0; // number of courses on the first line of the card numChoices = 0; // total number of courses provided on the card student_choices = new Vector(); // vector of course choices numEnrolled = 0; } public boolean lessThan (Comparable other) { if (student_id < ((Student)other).student_id) return true; else return false; } public boolean equals (Student other) { if (student_id == other.student_id) return true; else return false; } public void display () { System.out.print(student_id+" "+student_class+" "+numDesired+" "+ numChoices+" "+numEnrolled+" "); for (int i=0; i=10 || s[i] > t[i]) result = false; return result; } public boolean equals (Course other) { if (course_name.equals(other.course_name)) return true; else return false; } public void display () { System.out.println(course_name+" "+course_times+" "+capacity+" "+ enrollment+" "+rejections+" "+same_as+" "+title_instructor); } public void addToStats(Statistics stats, Vector conflicts) { int i; Conflict c = new Conflict(); stats.num_courses++; for (i=0; i=0; i--) System.out.print(i + " = " + stats.wanting[i] + " "); System.out.println(" courses"); System.out.print("Number of students getting "); for (int i=4; i>=0; i--) System.out.print(i + " = " + stats.getting[i] + " "); System.out.println(" courses"); System.out.println("Number of rejections for time conflicts: " + stats.time_rejections); System.out.println("Number of rejections for capacity exceeded: " + stats.capacity_rejections); } public static void displayTimings(Statistics stats) { System.out.println(); System.out.println("Run Time Statistics"); System.out.println(); System.out.println("Time to load the course file: " + stats.load_time + " ms."); System.out.println("Time to register the students: " + stats.register_time + " ms."); System.out.println("Average time to register a student: " + stats.register_time/stats.num_students + " ms."); long t = stats.load_time + stats.register_time; System.out.println("Total run time: " + t + " ms."); } public static boolean hasConflict(String course_times, Vector times_received, Vector conflicts) { // see if the times of a course is in conflict with any of the times // for courses the student has already received. boolean result = false; int i, j; Conflict c = new Conflict(); for (j=0; j=courses.size()) break; // course not offered; try next choice // check for "same as" course if (a_course.same_as!="") { a_name = a_course.same_as; for (j=0; j