Added method to check if a boat is finished the race or not.

- updated server if all boats finish the race, then start sending race finished message.
- race simulator will terminate if all boats finish the race, and prints log.

#story[715]
This commit is contained in:
Haoming Yin
2017-05-03 22:44:25 +12:00
parent d992422efd
commit ed8781b382
3 changed files with 42 additions and 21 deletions
@@ -65,6 +65,8 @@ public class Simulator extends Observable implements Runnable {
e.printStackTrace();
}
}
System.out.println("[SERVER] Race simulator has been terminated");
}
/**
@@ -89,7 +91,10 @@ public class Simulator extends Observable implements Runnable {
boat.setHeadingCorner(boat.getLastPassedCorner().getNextCorner());
// heading corner == null means boat has reached the final mark
if (boat.getHeadingCorner() == null) return 1;
if (boat.getHeadingCorner() == null) {
boat.setFinished(true);
return 1;
}
// move compensate distance for the mark just passed
Position pos = GeoUtility.getGeoCoordinate(