Class Grade


public class Grade extends 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
    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
    Returns the value of the grade as a double.
    int
    Returns a hash code value for the object.
    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 Details

    • 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 Details

    • getValue

      public double getValue()
      Returns the value of the grade as a double.
      Returns:
      the value of the grade
    • toString

      public String toString()
      Returns a string representation of the grade in the format X.X/20.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the grade
    • averageGrade

      public static 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.
      Parameters:
      grades - a list of grades
      Returns:
      a grade corresponding to the mean of grade in grades
    • equals

      public boolean equals(Object o)
      Determines whether 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 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 Object
      Returns:
      a hash code value for this object.