Package at.jku.ssw.fp.sect04_2.fp
Class Results
- java.lang.Object
-
- at.jku.ssw.fp.sect04_2.fp.Results
-
public class Results extends Object
Class representing the results of a student.- Author:
- Herbert Praehofer
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <A,R>
Rcompute(A start, BiFunction<? super A,Integer,? extends A> accumulator, Function<? super A,? extends R> finalizer)
Computes a result from the scores.int
countScores(IntPredicate countPredicate)
Counts the scores fulfilling a given predicate.Grade
getGrade(Function<Results,Grade> gradingFn)
Computes the grades using a function object to compute the grades from the assignment scores.String
getName()
Returns the name of the student.int
getScore(int assignment)
Returns the score of an assignment.int[]
getScores()
Returns the array of the scores for theN
assignments.String
getStdId()
Returns the id of the student.void
setScore(int assignment, int score)
Sets the score of an assignment.void
setScores(int... scores)
Sets the scores for theN
assignments.
-
-
-
Field Detail
-
N
private static final int N
Number of assignments- See Also:
- Constant Field Values
-
id
private final String id
The student id
-
name
private final String name
The name of the student
-
scores
private final int[] scores
The array of scores for the different assignments
-
-
Method Detail
-
getStdId
public String getStdId()
Returns the id of the student.- Returns:
- the id of the student
-
getName
public String getName()
Returns the name of the student.- Returns:
- the name of the student
-
getScore
public int getScore(int assignment)
Returns the score of an assignment.- Parameters:
assignment
- the number of the assignment.- Returns:
- the score of the assignment
-
getScores
public int[] getScores()
Returns the array of the scores for theN
assignments.- Returns:
- the array of the scores
-
setScore
public void setScore(int assignment, int score)
Sets the score of an assignment.- Parameters:
assignment
- the number of the assignmentscore
- the score for the assignment
-
setScores
public void setScores(int... scores)
Sets the scores for theN
assignments.- Parameters:
scores
- the array with the scores
-
getGrade
public Grade getGrade(Function<Results,Grade> gradingFn)
Computes the grades using a function object to compute the grades from the assignment scores.- Parameters:
gradingFn
- the function object- Returns:
- the grade
-
countScores
public int countScores(IntPredicate countPredicate)
Counts the scores fulfilling a given predicate.- Parameters:
countPredicate
- the predicate to test the scores- Returns:
- the number of scores fulfilling the given predicate
-
compute
public <A,R> R compute(A start, BiFunction<? super A,Integer,? extends A> accumulator, Function<? super A,? extends R> finalizer)
Computes a result from the scores. Uses an accumulator and a finalizer function.- Type Parameters:
A
- the type of the start and accumulated valueR
- the type of the result- Parameters:
start
- the start valueaccumulator
- the accumulator functionfinalizer
- the finalizer function- Returns:
- the computation result
-
-