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 Grade
averageGrade
(List<Grade> grades) Returns a grade with a value equals to the arithmetic mean of the values of the grade in the specified list.boolean
Determines whether two grades are equal.double
getValue()
Returns the value of the grade as a double.int
hashCode()
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 theirvalue
member field are the same. -
hashCode
public int hashCode()Returns a hash code value for the object.
-