/** GenotypeComparator.java * J Scott Cameron * * This class is used to compare two Genotype for sorting * Using this class will actually cause reverse-sorting * so that the best genotype is at the front of the Array */ import java.util.*; import java.io.*; public class GenotypeComparator implements Comparator { public GenotypeComparator() {} /* returns 1 if Genotype 1 is smaller * -1 if Genetype 1 is larger * and 0 if they are equal */ public int compare(Object o1, Object o2) { Genotype g1 = (Genotype)o1; Genotype g2 = (Genotype)o2; if(g1.getRating() < g2.getRating()) { return 1; } else if(g1.getRating() > g2.getRating()) { return -1; } return 0; } }