import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; public class CompareStudentScores { public static String[] studentNames = { "AdamBlank", "BarbaraHarris", "ChrisHill", "JessicaHernandez", "TeresaHall", }; public static void main(String[] args) throws FileNotFoundException { // java compares strings by... List quizzes = createQuizzes(3); // First, let's get a sorted list of the quizzes Collections.sort(quizzes); for (MCQuiz quiz : quizzes) { System.out.println(quiz); } /* Collect the quizzes for a particular student * together, and display all of the students * AdamBlank: [quiz0: 1/11, quiz1: 2/11] * BarbaraHarris: [quiz0: 3/11, quiz1: 3/11] * ... * You might need getStudent() * quizzes is a List */ Map> studentToQuizzes = new TreeMap<>(); for (MCQuiz quiz : quizzes) { String name = quiz.getStudent(); if (!studentToQuizzes.containsKey(name)) { studentToQuizzes.put(name, new TreeSet()); } studentToQuizzes.get(name).add(quiz); } for (String student : studentToQuizzes.keySet()) { System.out.println(student + ": " + studentToQuizzes.get(student)); } } public static List createQuizzes(int numberOfQuizzes) throws FileNotFoundException { List quizzes = new ArrayList(); // Create all the quizzes for (int i = 0; i < numberOfQuizzes; i++) { for (String student : studentNames) { quizzes.add(new MCQuiz("quizzes/quiz" + i + "/" + student)); } } return quizzes; } }