Class Grade
java.lang.Object
Grade
A grade with a float value comprised between 0 and 20.
-
Constructor Summary
ConstructorsConstructorDescriptionGrade(double value) Constructs a grade with a value equals to the specifiedvalue. -
Method Summary
Modifier and TypeMethodDescriptionstatic GradeaverageGrade(List<Grade> grades) Returns a grade with a value equals to the arithmetic mean of the values of the grade in the specified list.booleanDetermines whether two grades are equal.doublegetValue()Returns the value of the grade as a double.inthashCode()Returns a hash code value for the object.toString()Returns a string representation of the grade in the format X.X/20.
-
Constructor Details
-
Grade
public Grade(double value) Constructs a grade with a value equals to the specifiedvalue.- Parameters:
value- the value of the constructed grade
-
-
Method Details
-
getValue
public double getValue()Returns the value of the grade as a double.- Returns:
- the value of the grade
-
toString
Returns a string representation of the grade in the format X.X/20. -
averageGrade
Returns a grade with a value equals to the arithmetic mean of the values of the grade in the specified list.- Parameters:
grades- a list of grades- Returns:
- a grade corresponding to the mean of grade in
grades
-
equals
Determines whether two grades are equal. Two instances of Grade are equal if the values of theirvaluemember field are the same. -
hashCode
public int hashCode()Returns a hash code value for the object.
-