diff --git a/src/main/java/seng302/server/simulator/Boat.java b/src/main/java/seng302/server/simulator/Boat.java index 3fd6eb87..c5b821bf 100644 --- a/src/main/java/seng302/server/simulator/Boat.java +++ b/src/main/java/seng302/server/simulator/Boat.java @@ -11,7 +11,6 @@ public class Boat { private double speed; // in mm/sec private String boatName, shortName, shorterName; - // haven't been used so far private Corner lastPassedCorner, headingCorner; public Boat(int sourceID, String boatName) { diff --git a/src/main/java/seng302/server/simulator/Simulator.java b/src/main/java/seng302/server/simulator/Simulator.java index f76d0eec..1d285884 100644 --- a/src/main/java/seng302/server/simulator/Simulator.java +++ b/src/main/java/seng302/server/simulator/Simulator.java @@ -62,11 +62,11 @@ public class Simulator extends Observable implements Runnable { } /** - * Moves a boat with give time duration. + * Moves a boat with given time duration. * * @param boat the boat to be moved - * @param duration the moving duration in millisecond - * @return 1 if boat reached final line, otherwise 0 + * @param duration the moving duration in milliseconds + * @return 1 if the boat has reached the final line, otherwise return 0 */ private int moveBoat(Boat boat, double duration) { if (boat.getHeadingCorner() != null) { @@ -100,6 +100,11 @@ public class Simulator extends Observable implements Runnable { return 0; } + /** + * Link all the corners in the course list so that every corner knows its next + * corner, as well as the distance and bearing to its next corner. However, + * the last corner's heading is null, which means it is the final line. + */ private void setLegs() { // get the bearing from one mark to the next heading mark for (int i = 0; i < course.size() - 1; i++) { diff --git a/src/main/java/seng302/server/simulator/parsers/RaceParser.java b/src/main/java/seng302/server/simulator/parsers/RaceParser.java index 363da64f..14bf7bb8 100644 --- a/src/main/java/seng302/server/simulator/parsers/RaceParser.java +++ b/src/main/java/seng302/server/simulator/parsers/RaceParser.java @@ -9,7 +9,6 @@ import seng302.server.simulator.mark.Corner; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** * Parses the race xml file to get course details @@ -26,11 +25,20 @@ public class RaceParser extends FileParser { this.doc = this.parseFile(); } + /** + * Parses race.xml file and returns a list of corner which is the race course. + * @return a list of ordered corner to represent the course. + */ public List getCourse() { CourseParser cp = new CourseParser(path); return cp.getCourse(); } + /** + * Parses race.xml file and return a list of boats which will compete in the + * race. + * @return a list of boats that are going to compete in the race. + */ public List getBoats() { NodeList yachts = doc.getDocumentElement().getElementsByTagName("Yacht"); List boats = new ArrayList<>(); @@ -41,6 +49,11 @@ public class RaceParser extends FileParser { return boats; } + /** + * Parses a single boat from the given node + * @param node a node within a boat tag + * @return a boat instance parsed from the given node + */ private Boat getBoat(Node node) { if (node.getNodeType() == Node.ELEMENT_NODE) { Element e = (Element) node;