Class Grade
- java.lang.Object
-
- Grade
-
public class Grade extends java.lang.ObjectA grade with a float value comprised between 0 and 20.
-
-
Constructor Summary
Constructors Constructor Description Grade(double value)Constructs a grade with a value equals to the specifiedvalue.
-
Method Summary
Modifier and Type Method Description static GradeaverageGrade(java.util.List<Grade> grades)Returns a grade with a value equals to the arithmetic mean of the values of the grade in the specified list.booleanequals(java.lang.Object o)Determines whether or not two grades are equal.doublegetValue()Returns the value of the grade as a double.inthashCode()Returns a hash code value for the object.java.lang.StringtoString()Returns a string representation of the grade in the format X.X/20.
-
-
-
Method Detail
-
getValue
public double getValue()
Returns the value of the grade as a double.- Returns:
- the value of the grade
-
toString
public java.lang.String toString()
Returns a string representation of the grade in the format X.X/20.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of the grade
-
averageGrade
public static Grade averageGrade(java.util.List<Grade> grades)
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
public boolean equals(java.lang.Object o)
Determines whether or not two grades are equal. Two instances of Grade are equal if the values of theirvaluemember field are the same.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- an object to be compared with this Grade- Returns:
trueif the object to be compared is an instance of Grade and has the same value;falseotherwise.
-
hashCode
public int hashCode()
Returns a hash code value for the object.- Overrides:
hashCodein classjava.lang.Object- Returns:
- a hash code value for this object.
-
-