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;
|
import java.util.Random;
|
||||||
|
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a race object for the AC35 course
|
* Builds a race object for the AC35 course
|
||||||
|
*
|
||||||
|
* @return a Race object for the AC35 course
|
||||||
*/
|
*/
|
||||||
public static Race createRace() throws Exception {
|
public static Race createRace() throws Exception {
|
||||||
Race race = new Race();
|
Race race = new Race();
|
||||||
@@ -60,7 +63,7 @@ public class App {
|
|||||||
try {
|
try {
|
||||||
race = createRace();
|
race = createRace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println(e);
|
System.out.println("There was an error creating the race.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If race was created
|
// If race was created
|
||||||
@@ -71,14 +74,18 @@ public class App {
|
|||||||
System.out.println("######################");
|
System.out.println("######################");
|
||||||
System.out.println("# Live Race Updates ");
|
System.out.println("# Live Race Updates ");
|
||||||
System.out.println("######################");
|
System.out.println("######################");
|
||||||
|
|
||||||
race.startRace();
|
race.startRace();
|
||||||
|
|
||||||
|
|
||||||
System.out.println("\n\n");
|
System.out.println("\n\n");
|
||||||
System.out.println("######################");
|
System.out.println("######################");
|
||||||
System.out.println("# Race Results ");
|
System.out.println("# Race Results ");
|
||||||
System.out.println("######################");
|
System.out.println("######################");
|
||||||
|
|
||||||
race.showRaceMarkerResults();
|
race.showRaceMarkerResults();
|
||||||
race.displayFinishingOrder();
|
race.displayFinishingOrder();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
System.out.println("There was an error creating the race.");
|
System.out.println("There was an error creating the race.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ package seng302;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
public class Event {
|
public class Event {
|
||||||
|
|
||||||
private long time;
|
private long time; // Time the event occurs
|
||||||
private Boat boat;
|
private Boat boat;
|
||||||
private Leg leg;
|
private Leg leg; // Leg of the race the event occurs on
|
||||||
private boolean isFinishingEvent = false;
|
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
|
* Event class containing the time of specific event, related team/boat, and
|
||||||
@@ -25,6 +24,15 @@ public class Event {
|
|||||||
this.leg = eventLeg;
|
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) {
|
public Event(long eventTime, Boat eventBoat, Leg eventLeg, boolean isFinishingEvent) {
|
||||||
this.time = eventTime;
|
this.time = eventTime;
|
||||||
this.boat = eventBoat;
|
this.boat = eventBoat;
|
||||||
@@ -96,10 +104,10 @@ public class Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call when the boat reaches the marker, this will tell the marker the order
|
* Called when the boat in this event passes
|
||||||
* in which boats pass it
|
* the marker.
|
||||||
*/
|
*/
|
||||||
public void addBoatToMarker() {
|
public void boatPassedMarker() {
|
||||||
this.leg.addBoatToMarker(boat);
|
this.leg.addBoatToMarker(boat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,11 +121,12 @@ public class Event {
|
|||||||
/**
|
/**
|
||||||
* Get a string that contains the timestamp and course information for this 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() {
|
public String getEventString() {
|
||||||
String currentHeading = Integer.toString(this.getLeg().getHeading());
|
String currentHeading = Integer.toString(this.getLeg().getHeading());
|
||||||
|
|
||||||
|
// This event is a boat finishing the race
|
||||||
if (this.isFinishingEvent) {
|
if (this.isFinishingEvent) {
|
||||||
return (this.getTimeString() + ", " + this.getBoat().getTeamName() + " finished the race");
|
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() {
|
public boolean getIsFinishingLeg() {
|
||||||
return this.isFinishingLeg;
|
return this.isFinishingLeg;
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ public class Race {
|
|||||||
|
|
||||||
// I just simply print it out for testing
|
// I just simply print it out for testing
|
||||||
System.out.println(nextEvent.getEventString());
|
System.out.println(nextEvent.getEventString());
|
||||||
nextEvent.addBoatToMarker();
|
nextEvent.boatPassedMarker();
|
||||||
|
|
||||||
if (nextEvent.getIsFinishingEvent()) {
|
if (nextEvent.getIsFinishingEvent()) {
|
||||||
this.finishingOrder.add(nextEvent.getBoat());
|
this.finishingOrder.add(nextEvent.getBoat());
|
||||||
|
|||||||
Reference in New Issue
Block a user