Package beispiel
Class Course
java.lang.Object
beispiel.Course
public class Course
extends java.lang.Object
This is the class Course. It represents a course that a Student can enroll in.
Each Course has a unique id, a name and a certain amount of ECTS.
-
Constructor Summary
Constructors Constructor Description Course(int id, java.lang.String name, int ects)
Creates a new Cousre object. -
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object o)
Checks if the given Object o is equal to this objectint
getEcts()
Returns the ECTS of the Courseint
getId()
Returns the unique id of the Coursejava.lang.String
getName()
Returns the name of the Courseint
hashCode()
void
setEcts(int ects)
Sets the ECTS of the Coursevoid
setName(java.lang.String name)
Sets the name of the Course
-
Constructor Details
-
Course
public Course(int id, java.lang.String name, int ects)Creates a new Cousre object. After the id is set, it cannot be changed later on. Each Course must be created with a unique id- Parameters:
id
- The unique id of the Coursename
- The name of the Courseects
- The amount of ects the Course gives
-
-
Method Details
-
getId
public int getId()Returns the unique id of the Course- Returns:
- The unique id of the Course
-
getName
public java.lang.String getName()Returns the name of the Course- Returns:
- The name of the Course
-
setName
public void setName(java.lang.String name)Sets the name of the Course- Parameters:
name
- The name of the Course
-
getEcts
public int getEcts()Returns the ECTS of the Course- Returns:
- The ECTS of the Course
-
setEcts
public void setEcts(int ects)Sets the ECTS of the Course- Parameters:
ects
- The ECTS of the Course
-
equals
public boolean equals(java.lang.Object o)Checks if the given Object o is equal to this object- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- The Object to compare to this object- Returns:
- Returns
true
, if the given object is a Course object which has the same id as this object,false
otherwise
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-