Package at.htl.timetableGenerator.model
Class TimeSlot
java.lang.Object
at.htl.timetableGenerator.model.TimeSlot
This class represents a time slot in a timetable.
A time slot is defined by a day of the week and an hour of the day.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this time slot is equal to the specified object.getDay()Returns the day of the week for this time slot.intgetHour()Returns the hour of the day for this time slot.inthashCode()Returns a hash code value for this time slot.@NotNull TimeSlotnextDay()Returns a new TimeSlot that represents the next day at the same hour.@NotNull TimeSlotnextHour()Returns a new TimeSlot that represents the same day at the next hour.@NotNull TimeSlotprevDay()Returns a new TimeSlot that represents the previous day at the same hour.@NotNull TimeSlotprevHour()Returns a new TimeSlot that represents the same day at the previous hour.voidSets the day of the week for this time slot.voidsetHour(int hour) Sets the hour of the day for this time slot.@NotNull StringtoString()Returns a string representation of this time slot.
-
Constructor Details
-
TimeSlot
Constructs a new TimeSlot with the specified day and hour.- Parameters:
day- the day of the weekhour- the hour of the day (0-indexed)
-
-
Method Details
-
getDay
Returns the day of the week for this time slot.- Returns:
- the day of the week
-
setDay
Sets the day of the week for this time slot.- Parameters:
day- the day of the week
-
getHour
public int getHour()Returns the hour of the day for this time slot.- Returns:
- the hour of the day
-
setHour
public void setHour(int hour) Sets the hour of the day for this time slot.- Parameters:
hour- the hour of the day
-
equals
Checks if this time slot is equal to the specified object. The result is true if and only if the argument is not null and is a TimeSlot object that has the same day and hour as this object. -
hashCode
public int hashCode()Returns a hash code value for this time slot. -
toString
Returns a string representation of this time slot. -
nextDay
Returns a new TimeSlot that represents the next day at the same hour.- Returns:
- a new TimeSlot that represents the next day at the same hour
-
prevDay
Returns a new TimeSlot that represents the previous day at the same hour.- Returns:
- a new TimeSlot that represents the previous day at the same hour
-
nextHour
Returns a new TimeSlot that represents the same day at the next hour.- Returns:
- a new TimeSlot that represents the same day at the next hour
-
prevHour
Returns a new TimeSlot that represents the same day at the previous hour. Throws an IllegalArgumentException if the hour is 0.- Returns:
- a new TimeSlot that represents the same day at the previous hour
- Throws:
IllegalArgumentException- if the hour is 0
-