Package at.jku.ssw.fp.sect04_2.imp
Class ResultsList
- java.lang.Object
-
- at.jku.ssw.fp.sect04_2.imp.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 Summary
Fields Modifier and Type Field Description private Map<String,Results>
resultsMap
Map of student ids to their results.
-
Constructor Summary
Constructors Constructor Description ResultsList()
Constructor initializing the map of results.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addStudent(String id, String name)
Adds a student to the list.double
avrgScores(int assignment)
Computes the average of points achieved in a particular assignment.double
avrgScores(String id)
Computes the average of the scores of a student.int
countSolved(int assignment)
Counts the number of students which have solved the given assignment.int
countSolved(String id)
Counts the assignments of a student which are solved.Grade
getGrade(String id)
Computes the grade from the scores for the given student.(package private) Results
getResults(String id)
Gets the result object for a student.int
getScore(String id, int assignment)
Gets the score of a student for a particular assignment.void
setScore(String id, int... scores)
Sets the scores for a student.void
setScore(String id, int assignment, int score)
Sets the score for a student for an assignment.
-
-
-
Method Detail
-
addStudent
public void addStudent(String id, String name)
Adds a student to the list.- Parameters:
id
- the id of the studentname
- 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 studentassignment
- the assignment numberscore
- the score
-
setScore
public void setScore(String id, int... scores)
Sets the scores for a student.- Parameters:
id
- the id of the studentscores
- 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 idassignment
- 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
-
-