/**
 * A class that can be used to compare the final grades in two
 * sections of the same course.
 *
 * This class is used to make sure that Prof. Bernstein gives
 * lower grades than the Professors teaching any other sections.
 * To that end, it compares the minimum grades, mean grades, and
 * maximum grades to make sure the values for his section are lower
 * than the values for the other section.
 *
 * The method in this class has (one or more) known bugs that
 * can be found using careful desk checking
 *
 * @author  Prof. David Bernstein
 * @version 1.0
 */
public class SectionComparator
{
    /**
     * Compare two grade arrays
     *
     * This method retuns -1 if the minimum, maximum and mean grades
     * are lower for bernsteinGrades than for otherGrades.
     *
     * This method returns 0 if the three statistics are the same
     * for both arrays.
     *
     * This method returns 1 otherwise.
     *
     * @param bernsteinGrades  The grades in Prof. Bernstein's sections
     * @param otherGrades      The grades in the other section
     * @return                 -1, 0, or 1
     */
    public int compare(int[] bernsteinGrades, int[] otherGrades)
    {
       double   bMax, bMean, bMin, oMax, oMean, oMin;
       int      result;
       
       
       bMax  = Statistics.max(bernsteinGrades);
       bMean = Statistics.mean(bernsteinGrades);
       bMin  = Statistics.min(bernsteinGrades);
       
       oMax  = Statistics.max(otherGrades);
       oMean = Statistics.mean(otherGrades);
       oMin  = Statistics.min(otherGrades);


       result = 1;
       
       
       if      ((bMax == oMax) && (bMean == oMean) && (bMin == oMin))
       {
          result = 0;          
       }
       else if ((bMax <  oMax) && (bMean <  oMean) && (bMin <  oMin))
       {
          result = -1;          
       }
       
       return result;       
    }
    

}
