CS 1713 Introduction to Computer Science -- Spring 2001
Practice Problem on Interfaces

Consider the following Student class (this class appeared also in the earlier practice problem about classes):

public class Student {
   private String name; // In the form "LastName, FirstName"
   private double GPA; // grade point average
   private int collegeClass; // 1 = FR, 2 = SO, 3 = JR, 4 = SR, 5 = GR

   public Student(){} // some reasonable constructor

   public double getGPA() {} // return the GPA
   // ...
}
Add to this class to that it implements the Comparable interface in two ways (two separate problems):
  1. Make the order of objects of the type of this class: decreasing order of GPA.
  2. Make the order of objects of the type of this class: increasing order of collegeClass, and in case the class is the same, alphabetic order by name.
  3. Assuming you have done the practice problem on classes above, add to the class that creates individual Student classes so that it stores references to these in an array of Comparable.
  4. Show how to use the insertionSort code (for objects) to sort this array into order, depending on how you implemented Comparable in parts 1 and 2 above.