-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from radford-transit/change-shift-change-time
Change shift change time
- Loading branch information
Showing
5 changed files
with
89 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,81 @@ | ||
package main; | ||
|
||
public class ShiftChange implements Comparable { | ||
/** Hour of the shift change */ | ||
public int hour; | ||
/** Start time of the shift change */ | ||
public TimePoint startTime; | ||
/** End time of the shift change */ | ||
public TimePoint endTime; | ||
/** ID of the shift change */ | ||
public ShiftChangeID id; | ||
|
||
/** | ||
* Constructs a ShiftChange object | ||
* | ||
* @param hour The hour of the shift change | ||
* @param startTime The start time of the shift change | ||
* @param endTime The end time of the shift change | ||
* @param id The ShiftChangeID to assign to the shift change | ||
*/ | ||
public ShiftChange(int hour, ShiftChangeID id) { | ||
this.hour = hour; | ||
public ShiftChange(TimePoint startTime, TimePoint endTime, ShiftChangeID id) { | ||
this.startTime = startTime; | ||
this.endTime = endTime; | ||
this.id = id; | ||
} | ||
|
||
/** | ||
* Constructs a ShiftChange object | ||
* | ||
* @param startHour The start hour of the shift change | ||
* @param startMinute The start minute of the shift change | ||
* @param endHour The end hour of the shift change | ||
* @param endMinute The end minute of the shift change | ||
* @param id The ShiftChangeID to assign to the shift change | ||
*/ | ||
public ShiftChange(int startHour, int startMinute, int endHour, int endMinute, ShiftChangeID id) { | ||
this(new TimePoint(startHour, startMinute), new TimePoint(endHour, endMinute), id); | ||
} | ||
|
||
/** | ||
* Constructs a ShiftChange object | ||
* | ||
* @param time The time of the shift change | ||
* @param id The ShiftChangeID to assign to the shift change | ||
*/ | ||
public ShiftChange(TimePoint time, ShiftChangeID id) { | ||
this.hour = time.hour; | ||
this.id = id; | ||
this(time, new TimePoint(time.hour, 50), id); | ||
} | ||
|
||
/** | ||
* Constructs a ShiftChange object | ||
* | ||
* @param hour The hour of the shift change | ||
* @param id The ShiftChangeID to assign to the shift change | ||
*/ | ||
public ShiftChange(int hour, ShiftChangeID id) { | ||
this(new TimePoint(hour, 10), id); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public String toString() { | ||
return new TimePoint(this.hour, 15).toString() | ||
+ " - " | ||
+ new TimePoint(this.hour + 1, 0).toString(); | ||
return startTime.toString() + " - " + endTime.toString(); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public int compareTo(Object other) { | ||
if (other instanceof ShiftChange) | ||
return (this.hour < ((ShiftChange) other).hour | ||
? -1 | ||
: this.hour == ((ShiftChange) other).hour ? 0 : 1); | ||
return this.startTime.compareTo(((ShiftChange) other).startTime); | ||
return -2; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public boolean equals(Object other) { | ||
if (other instanceof ShiftChange) | ||
return this.hour == ((ShiftChange) other).hour && this.id == ((ShiftChange) other).id; | ||
return this.startTime.equals(((ShiftChange) other).startTime) | ||
&& this.endTime.equals(((ShiftChange) other).endTime) | ||
&& this.id == ((ShiftChange) other).id | ||
; | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters