Source of SortStudents.java


  1: import java.util.Arrays;

  3: public class SortStudents {

  5:     public static void main(String[] args) {
  6:         // create list of Students
  7:         Student jake = new Student("Jake");
  8:         Student angie = new Student("Angie");
  9:         Student geety = new Student("Geety");
 10:         Student[] ss = new Student[]{jake, angie, geety};

 12:         // add grades to students and students to list
 13:         jake.setAsgnGrades(new int[]{75, 65});
 14:         angie.setAsgnGrades(new int[]{55, 65});
 15:         geety.setAsgnGrades(new int[]{95, 85});
 16:         Student.releaseAssignment(2);

 18:         // report original
 19:         System.out.println("\nHere is a list of Students:");
 20:         for (int i = 0; i < ss.length; ++i) {
 21:             ss[i].printStudentRecord();
 22:         }
 23:         System.out.println();

 25:         // sort and present sorted
 26:         Arrays.sort(ss);
 27:         System.out.println("\nHere is that same list, sorted by grade:");
 28:         for (int i = 0; i < ss.length; ++i) {
 29:             ss[i].printStudentRecord();
 30:         }
 31:         System.out.println();
 32:     }

 34: }