Package beispiel
Class Student
java.lang.Object
beispiel.Student
public class Student
extends java.lang.Object
This is the class Student. It represents a Student with a
name, birthdate and unique matnr.
-
Constructor Summary
Constructors Constructor Description Student(int matnr, java.lang.String name, java.time.LocalDate birthdate)
Creates a new Student object. -
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.time.LocalDate
getBirthdate()
Returns the birthdate of the studentint
getMatnr()
Returns the matnr of the Student.java.lang.String
getName()
Returns the name of the student as a single String (first and last name)int
hashCode()
void
joinCourse(Course course)
Adds the Course to the Student's course listvoid
leaveCourse(Course course)
Removes a Course from the Student's course listvoid
setBirthdate(java.time.LocalDate birthdate)
Sets the birthdate of the studentvoid
setName(java.lang.String name)
Sets the name of the student as a single String (first and last name)
-
Constructor Details
-
Student
public Student(int matnr, java.lang.String name, java.time.LocalDate birthdate)Creates a new Student object. After the matnr. is set, it cannot be changed later on. Each student must be created with a unique matnr.- Parameters:
matnr
- The unique matnr. of the Studentname
- The name of the Studentbirthdate
- The birthdate of the Student
-
-
Method Details
-
getMatnr
public int getMatnr()Returns the matnr of the Student. Each student has a unique matnr.- Returns:
- The matnr of the Student
-
getName
public java.lang.String getName()Returns the name of the student as a single String (first and last name)- Returns:
- The first and last name of the Student a a single String
-
setName
public void setName(java.lang.String name)Sets the name of the student as a single String (first and last name)- Parameters:
name
- The first and last name of the Student a a single String
-
getBirthdate
public java.time.LocalDate getBirthdate()Returns the birthdate of the student- Returns:
- The birthdate of the student
-
setBirthdate
public void setBirthdate(java.time.LocalDate birthdate)Sets the birthdate of the student- Parameters:
birthdate
- The birthdate of the student
-
joinCourse
Adds the Course to the Student's course list- Parameters:
course
- The course to add
-
leaveCourse
Removes a Course from the Student's course list- Parameters:
course
- The course to leave
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-