fixes Bug 99 by slightly modifying the specification of TrackedLegOfCompetitor.getTimeInMilliseconds

This commit is contained in:
Axel Uhl committed 2011-12-03 12:08:26 +01:00
1 parent 32cc72e7dd
commit 4d518e7bc0
2 files changed
+12 -9

No files matched your search

@@ -15,8 +15,10 @@ public interface TrackedLegOfCompetitor {
Competitor getCompetitor();
/**
* How long did it take the competitor to complete this {@link #getLeg() leg}? If the competitor hasn't finished the
* leg yet, -1 is returned.
* How much time did the {@link #getCompetitor competitor} spend in this {@link #getLeg() leg} at
* <code>timePoint</code>? If the competitor hasn't started the leg yet at <code>timePoint</code>, 0 is returned. If the
* competitor has finished the leg already at <code>timePoint</code>, the time it took the competitor to
* complete the leg is returned.
*/
long getTimeInMilliSeconds(TimePoint timePoint);
@@ -59,15 +59,16 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor {
@Override
public long getTimeInMilliSeconds(TimePoint timePoint) {
long result = -1;
MarkPassing passedEndWaypoint = getTrackedRace().getMarkPassing(getCompetitor(), getTrackedLeg().getLeg().getTo());
if (passedEndWaypoint != null) {
MarkPassing passedStartWaypoint = getTrackedRace().getMarkPassing(getCompetitor(), getTrackedLeg().getLeg().getFrom());
if (passedStartWaypoint != null) {
long result = 0;
MarkPassing passedStartWaypoint = getTrackedRace().getMarkPassing(getCompetitor(),
getTrackedLeg().getLeg().getFrom());
if (passedStartWaypoint != null) {
MarkPassing passedEndWaypoint = getTrackedRace().getMarkPassing(getCompetitor(),
getTrackedLeg().getLeg().getTo());
if (passedEndWaypoint != null) {
result = passedEndWaypoint.getTimePoint().asMillis() - passedStartWaypoint.getTimePoint().asMillis();
} else {
throw new RuntimeException(""+getCompetitor()+" passed waypoint at end of leg "+
getLeg()+" without having passed waypoint at beginning of leg");
result = timePoint.asMillis() - passedStartWaypoint.getTimePoint().asMillis();
}
}
return result;