mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Added and fixed docstrings
Tags #docs
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user