Class Student


public class Student extends Object
A students with results.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Student(String firstName, String lastName)
    Constructs a student with the specified first name and last name and no associated results.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addResult(String teachingUnitName, Grade grade)
    Add a grade associated to a teaching unit to the results of the student.
    Returns the average grade of the student.
    boolean
    Determines whether or not two students are equal.
    Returns the grades of the student.
    int
    Returns a hash code value for the object.
    void
    Print via the standard output the name of the student, all results associated to the students and the average grade of the student.
    Returns a string representation of the student in the format first name last name.

    Methods inherited from class java.lang.Object

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

    • Student

      public Student(String firstName, String lastName)
      Constructs a student with the specified first name and last name and no associated results.
      Parameters:
      firstName - the first name of the constructed student
      lastName - the last name of the constructed student
  • Method Details

    • addResult

      public void addResult(String teachingUnitName, Grade grade)
      Add a grade associated to a teaching unit to the results of the student.
      Parameters:
      teachingUnitName - the name of the teaching unit of the added result
      grade - the grade of the added result
    • toString

      public String toString()
      Returns a string representation of the student in the format first name last name.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the student
    • getGrades

      public List<Grade> getGrades()
      Returns the grades of the student.
      Returns:
      the grades of the student
    • averageGrade

      public Grade averageGrade()
      Returns the average grade of the student.
      Returns:
      the average grade of the student
    • printResults

      public void printResults()
      Print via the standard output the name of the student, all results associated to the students and the average grade of the student.
    • equals

      public boolean equals(Object o)
      Determines whether or not two students are equal. Two instances of Student are equal if the values of their firtName and lastName member fields are the same.
      Overrides:
      equals in class Object
      Parameters:
      o - an object to be compared with this Student
      Returns:
      true if the object to be compared is an instance of Student and has the same name; 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.