import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

/**
 * A program to sort Student objects in three ways -- defined in the Student 
 * class. This program is the same for all three variations of the Student class
 * (found in the folders named withClasses, anonymous and lambdas). Compare this
 * version with the one in folder natural, in which the Student class defines no
 * comparators.
 *
 * @author Mark Young (A00000000)
 */
public class SortStudents {

    public static void main(String[] args) {
        // create list of Students
        List<Student> ss = new ArrayList<Student>();
        Student jake = new Student("Jake");
        Student angie = new Student("Angie");
        Student geety = new Student("Geety");

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

        // report original
        System.out.println("\nHere is a list of Students:");
        for (Student s : ss) {
            s.printStudentRecord();
        }
        pause();

        // sort and present sorted
        Collections.sort(ss, Student.BY_NAME);
        System.out.println("\nHere is that same list, sorted by name:");
        for (Student s : ss) {
            s.printStudentRecord();
        }
        pause();

        // sort and present sorted
        Collections.sort(ss, Student.BY_GRADE);
        System.out.println("\nHere is that same list, sorted by grade:");
        for (Student s : ss) {
            s.printStudentRecord();
        }
        pause();

        // sort and present sorted
        Collections.sort(ss, Student.BY_ANUMBER);
        System.out.println("\nHere is that same list, sorted by A-#:");
        for (Student s : ss) {
            s.printStudentRecord();
        }
        pause();

        // sort and present sorted
        Collections.sort(ss);
        System.out.println("\nHere is that same list, in its natural order:");
        for (Student s : ss) {
            s.printStudentRecord();
        }
        pause();
    }

    private static void pause() {
        Scanner kbd = new Scanner(System.in);
        System.out.print("\nPress enter...");
        kbd.nextLine();
        System.out.println();
    }
}
