Class Grade


  • public class Grade
    extends java.lang.Object
    A 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 specified value.
    • Method Summary

      Modifier and Type Method Description
      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.
      boolean equals​(java.lang.Object o)
      Determines whether or not 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.
      java.lang.String toString()
      Returns a string representation of the grade in the format X.X/20.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Grade

        public Grade​(double value)
        Constructs a grade with a value equals to the specified value.
        Parameters:
        value - the value of the constructed grade
    • 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:
        toString in class java.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 their value member field are the same.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - an object to be compared with this Grade
        Returns:
        true if the object to be compared is an instance of Grade and has the same value; false otherwise.
      • hashCode

        public int hashCode()
        Returns a hash code value for the object.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hash code value for this object.