From ae80b434f68bac9e52cc3c4f218a57a738db6d4a Mon Sep 17 00:00:00 2001 From: Michael Rausch Date: Wed, 8 Mar 2017 22:25:52 +1300 Subject: [PATCH] Added and fixed docstrings Tags #docs --- src/main/java/seng302/App.java | 9 ++++++++- src/main/java/seng302/Event.java | 27 ++++++++++++++++++--------- src/main/java/seng302/Leg.java | 3 ++- src/main/java/seng302/Race.java | 2 +- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/main/java/seng302/App.java b/src/main/java/seng302/App.java index 2919abe3..68f5b596 100644 --- a/src/main/java/seng302/App.java +++ b/src/main/java/seng302/App.java @@ -7,8 +7,11 @@ import java.util.Map; import java.util.Random; public class App { + /** * Builds a race object for the AC35 course + * + * @return a Race object for the AC35 course */ public static Race createRace() throws Exception { Race race = new Race(); @@ -60,7 +63,7 @@ public class App { try { race = createRace(); } catch (Exception e) { - System.out.println(e); + System.out.println("There was an error creating the race."); } // If race was created @@ -71,14 +74,18 @@ public class App { System.out.println("######################"); System.out.println("# Live Race Updates "); System.out.println("######################"); + race.startRace(); + System.out.println("\n\n"); System.out.println("######################"); System.out.println("# Race Results "); System.out.println("######################"); + race.showRaceMarkerResults(); race.displayFinishingOrder(); + } else { System.out.println("There was an error creating the race."); } diff --git a/src/main/java/seng302/Event.java b/src/main/java/seng302/Event.java index 1148f8c7..3dc0e87c 100644 --- a/src/main/java/seng302/Event.java +++ b/src/main/java/seng302/Event.java @@ -3,13 +3,12 @@ package seng302; import java.text.SimpleDateFormat; import java.util.Date; - public class Event { - private long time; - private Boat boat; - private Leg leg; - private boolean isFinishingEvent = false; + private long time; // Time the event occurs + private Boat boat; + private Leg leg; // Leg of the race the event occurs on + private boolean isFinishingEvent = false; // This event occurs when a boat finishes the race /** * Event class containing the time of specific event, related team/boat, and @@ -25,6 +24,15 @@ public class Event { this.leg = eventLeg; } + /** + * Event class containing the time of specific event, related team/boat, and + * event location such as leg. + * + * @param eventTime, what time the event happens + * @param eventBoat, the boat that the event belongs to + * @param eventLeg, the leg the event happens on + * @param isFinishingEvent, true if this event is the boat crossing the finishing line + */ public Event(long eventTime, Boat eventBoat, Leg eventLeg, boolean isFinishingEvent) { this.time = eventTime; this.boat = eventBoat; @@ -96,10 +104,10 @@ public class Event { } /** - * Call when the boat reaches the marker, this will tell the marker the order - * in which boats pass it + * Called when the boat in this event passes + * the marker. */ - public void addBoatToMarker() { + public void boatPassedMarker() { this.leg.addBoatToMarker(boat); } @@ -113,11 +121,12 @@ public class Event { /** * Get a string that contains the timestamp and course information for this event * - * @return A string that contains the timestamp and course information for this event + * @return A string that details what happened in this event */ public String getEventString() { String currentHeading = Integer.toString(this.getLeg().getHeading()); + // This event is a boat finishing the race if (this.isFinishingEvent) { return (this.getTimeString() + ", " + this.getBoat().getTeamName() + " finished the race"); } diff --git a/src/main/java/seng302/Leg.java b/src/main/java/seng302/Leg.java index 4c83c9ce..59966744 100644 --- a/src/main/java/seng302/Leg.java +++ b/src/main/java/seng302/Leg.java @@ -100,7 +100,8 @@ public class Leg { } /** - * @returns true if this the race finishes after this leg + * Returns whether or not the race finishes after this leg + * @return true if this the race finishes after this leg */ public boolean getIsFinishingLeg() { return this.isFinishingLeg; diff --git a/src/main/java/seng302/Race.java b/src/main/java/seng302/Race.java index f9973b43..ad0c4578 100644 --- a/src/main/java/seng302/Race.java +++ b/src/main/java/seng302/Race.java @@ -199,7 +199,7 @@ public class Race { // I just simply print it out for testing System.out.println(nextEvent.getEventString()); - nextEvent.addBoatToMarker(); + nextEvent.boatPassedMarker(); if (nextEvent.getIsFinishingEvent()) { this.finishingOrder.add(nextEvent.getBoat());