Class ResultsList


  • public class ResultsList
    extends Object
    Class for representing and maintaining a list of result records for a set of students.
    Author:
    Herbert Praehofer
    • Field Detail

      • resultsMap

        private final Map<String,​Results> resultsMap
        Map of student ids to their results.
    • Constructor Detail

      • ResultsList

        public ResultsList()
        Constructor initializing the map of results.
    • Method Detail

      • addStudent

        public void addStudent​(String id,
                               String name)
        Adds a student to the list.
        Parameters:
        id - the id of the student
        name - the name of the student
      • setScore

        public void setScore​(String id,
                             int assignment,
                             int score)
        Sets the score for a student for an assignment.
        Parameters:
        id - the id of the student
        assignment - the assignment number
        score - the score
      • setScore

        public void setScore​(String id,
                             int... scores)
        Sets the scores for a student.
        Parameters:
        id - the id of the student
        scores - the scores for the assignments
      • getResults

        Results getResults​(String id)
        Gets the result object for a student.
        Parameters:
        id - the id of the student
        Returns:
        the result object
      • getScore

        public int getScore​(String id,
                            int assignment)
        Gets the score of a student for a particular assignment.
        Parameters:
        id - the student id
        assignment - the assignment number
        Returns:
        the score
      • countSolved

        public int countSolved​(String id)
        Counts the assignments of a student which are solved. An assignment is solved if 40% of the points have been achieved.
        Parameters:
        id - the student id
        Returns:
        the number of solved assignments
      • avrgScores

        public double avrgScores​(String id)
        Computes the average of the scores of a student.
        Parameters:
        id - the student id
        Returns:
        the average of the scores of the student
      • getGrade

        public Grade getGrade​(String id)
        Computes the grade from the scores for the given student.
        Parameters:
        id - the student id
        Returns:
        the grade
      • countSolved

        public int countSolved​(int assignment)
        Counts the number of students which have solved the given assignment.
        Parameters:
        assignment - the number of the assignment
        Returns:
        the number of students solved the assignment
      • avrgScores

        public double avrgScores​(int assignment)
        Computes the average of points achieved in a particular assignment.
        Parameters:
        assignment - the number of the assignment
        Returns:
        the average for this assignment