16.6. StudentAnswerSheet - Part B

Part b. Consider the following class that represents the test results of a group of students that took a multiple-choice test.

public class TestResults
{
   private List<StudentAnswerSheet> sheets;

   /** Precondition: sheets.size() > 0;
    *                all answer sheets in sheets have the same number of answers
    *  @param key the list of correct answers represented as strings of length one
    *         Precondition: key.size() is equal to the number of answers in each
    *                       of the answer sheets in sheets
    *  @return the name of the student with the highest score
    */
  public String highestScoringStudent(List<String> key)
  {
    /* to be implemented in part (b) */
  }

  // There may be fields, constructors, and methods that are not shown.
}

Write the TestResults method highestScoringStudent, which returns the name of the student who received the highest score on the test represented by the parameter key. If there is more than one student with the highest score, the name of any one of these highest-scoring students may be returned. You may assume that the size of each answer sheet represented in sheets is equal to the size of key.

16.6.1. Try and Solve It

Complete method highestScoringStudent below.

The code below has a main method for testing the highestScoringStudent method.

Next Section - 16.7. SkyView - Part A