mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Reformatted doctring and import statements
This commit is contained in:
@@ -1,13 +1,31 @@
|
|||||||
{
|
{
|
||||||
"race-name": "AC35",
|
"race-name": "AC35",
|
||||||
"time-scale": 1.0,
|
"time-scale": 1.0,
|
||||||
"race-size": 4,
|
"race-size": 6,
|
||||||
"teams": [
|
"teams": [
|
||||||
{"team-name": "Oracle Team USA", "velocity": 20.9},
|
{
|
||||||
{"team-name": "Artemis Racing", "velocity": 18.3},
|
"team-name": "Oracle Team USA",
|
||||||
{"team-name": "Emirates Team New Zealand", "velocity": 21.5},
|
"velocity": 20.9
|
||||||
{"team-name": "Groupama Team France","velocity": 19.9},
|
},
|
||||||
{"team-name": "Land Rover BAR", "velocity": 17.6},
|
{
|
||||||
{"team-name": "SoftBank Team Japan", "velocity": 16.6}
|
"team-name": "Artemis Racing",
|
||||||
|
"velocity": 18.3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"team-name": "Emirates Team New Zealand",
|
||||||
|
"velocity": 21.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"team-name": "Groupama Team France",
|
||||||
|
"velocity": 19.9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"team-name": "Land Rover BAR",
|
||||||
|
"velocity": 17.6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"team-name": "SoftBank Team Japan",
|
||||||
|
"velocity": 16.6
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>seng302</groupId>
|
<groupId>seng302</groupId>
|
||||||
@@ -40,7 +40,8 @@
|
|||||||
<version>2.4.3</version>
|
<version>2.4.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<transformers>
|
<transformers>
|
||||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
<transformer
|
||||||
|
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
<Main-Class>seng302.App</Main-Class>
|
<Main-Class>seng302.App</Main-Class>
|
||||||
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
|
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
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
|
||||||
*/
|
*/
|
||||||
@@ -52,14 +54,12 @@ public class App
|
|||||||
return race;
|
return race;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main( String[] args )
|
public static void main(String[] args) {
|
||||||
{
|
|
||||||
Race race = null;
|
Race race = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
race = createRace();
|
race = createRace();
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e){
|
|
||||||
System.out.println(e);
|
System.out.println(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,8 +79,7 @@ public class App
|
|||||||
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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a boat in the race.
|
public class Boat {
|
||||||
*
|
|
||||||
* @param teamName The name of the team sailing the boat
|
|
||||||
* @param boatVelocity The speed of the boat in meters/second
|
|
||||||
*/
|
|
||||||
public class Boat
|
|
||||||
{
|
|
||||||
|
|
||||||
private String teamName; // The name of the team, this is also the name of the boat
|
private String teamName; // The name of the team, this is also the name of the boat
|
||||||
private double velocity; // In meters/second
|
private double velocity; // In meters/second
|
||||||
@@ -17,6 +11,12 @@ public class Boat
|
|||||||
this.velocity = 10; // Default velocity
|
this.velocity = 10; // Default velocity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a boat in the race.
|
||||||
|
*
|
||||||
|
* @param teamName The name of the team sailing the boat
|
||||||
|
* @param boatVelocity The speed of the boat in meters/second
|
||||||
|
*/
|
||||||
public Boat(String teamName, double boatVelocity) {
|
public Boat(String teamName, double boatVelocity) {
|
||||||
this.teamName = teamName;
|
this.teamName = teamName;
|
||||||
this.velocity = boatVelocity;
|
this.velocity = boatVelocity;
|
||||||
@@ -24,6 +24,7 @@ public class Boat
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the team sailing the boat
|
* Returns the name of the team sailing the boat
|
||||||
|
*
|
||||||
* @return The name of the team
|
* @return The name of the team
|
||||||
*/
|
*/
|
||||||
public String getTeamName() {
|
public String getTeamName() {
|
||||||
@@ -32,25 +33,28 @@ public class Boat
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the name of the team sailing the boat
|
* Sets the name of the team sailing the boat
|
||||||
|
*
|
||||||
* @param teamName The name of the team
|
* @param teamName The name of the team
|
||||||
*/
|
*/
|
||||||
public void setTeamName(String teamName) {
|
public void setTeamName(String teamName) {
|
||||||
this.teamName = teamName;
|
this.teamName = teamName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets velocity of the boat
|
|
||||||
* @param velocity The velocity of boat
|
|
||||||
*/
|
|
||||||
public void setVelocity(float velocity) {
|
|
||||||
this.velocity = velocity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets velocity of the boat
|
* Gets velocity of the boat
|
||||||
|
*
|
||||||
* @return a float number of the boat velocity
|
* @return a float number of the boat velocity
|
||||||
*/
|
*/
|
||||||
public double getVelocity() {
|
public double getVelocity() {
|
||||||
return this.velocity;
|
return this.velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets velocity of the boat
|
||||||
|
*
|
||||||
|
* @param velocity The velocity of boat
|
||||||
|
*/
|
||||||
|
public void setVelocity(float velocity) {
|
||||||
|
this.velocity = velocity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,14 @@ package seng302;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
public class Event {
|
||||||
|
|
||||||
|
private long time;
|
||||||
|
private Boat boat;
|
||||||
|
private Leg leg;
|
||||||
|
private boolean isFinishingEvent = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event class containing the time of specific event, related team/boat, and
|
* Event class containing the time of specific event, related team/boat, and
|
||||||
* event location such as leg.
|
* event location such as leg.
|
||||||
@@ -11,13 +19,6 @@ import java.util.Date;
|
|||||||
* @param eventBoat, the boat that the event belongs to
|
* @param eventBoat, the boat that the event belongs to
|
||||||
* @param eventLeg, the leg the event happens on
|
* @param eventLeg, the leg the event happens on
|
||||||
*/
|
*/
|
||||||
public class Event {
|
|
||||||
|
|
||||||
private long time;
|
|
||||||
private Boat boat;
|
|
||||||
private Leg leg;
|
|
||||||
private boolean isFinishingEvent = false;
|
|
||||||
|
|
||||||
public Event(long eventTime, Boat eventBoat, Leg eventLeg) {
|
public Event(long eventTime, Boat eventBoat, Leg eventLeg) {
|
||||||
this.time = eventTime;
|
this.time = eventTime;
|
||||||
this.boat = eventBoat;
|
this.boat = eventBoat;
|
||||||
@@ -31,40 +32,36 @@ public class Event {
|
|||||||
this.isFinishingEvent = isFinishingEvent;
|
this.isFinishingEvent = isFinishingEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the time for the event
|
|
||||||
* @param eventTime the time for event in millisecond
|
|
||||||
*/
|
|
||||||
public void setTime(long eventTime) {
|
|
||||||
this.time = eventTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the time for the event
|
* Gets the time for the event
|
||||||
|
*
|
||||||
* @return the time for event in millisecond
|
* @return the time for event in millisecond
|
||||||
*/
|
*/
|
||||||
public long getTime() {
|
public long getTime() {
|
||||||
return this.time;
|
return this.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the time for the event
|
||||||
|
*
|
||||||
|
* @param eventTime the time for event in millisecond
|
||||||
|
*/
|
||||||
|
public void setTime(long eventTime) {
|
||||||
|
this.time = eventTime;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the time in a formatted string
|
* Gets the time in a formatted string
|
||||||
|
*
|
||||||
* @return the string of time
|
* @return the string of time
|
||||||
*/
|
*/
|
||||||
public String getTimeString() {
|
public String getTimeString() {
|
||||||
return (new SimpleDateFormat("mm:ss:SSS")).format(new Date(time));
|
return (new SimpleDateFormat("mm:ss:SSS")).format(new Date(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the involved boat
|
|
||||||
* @param eventBoat the involved boat
|
|
||||||
*/
|
|
||||||
public void setBoat(Boat eventBoat) {
|
|
||||||
this.boat = eventBoat;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the involved boat
|
* Gets the involved boat
|
||||||
|
*
|
||||||
* @return the boat involved in the event
|
* @return the boat involved in the event
|
||||||
*/
|
*/
|
||||||
public Boat getBoat() {
|
public Boat getBoat() {
|
||||||
@@ -72,21 +69,32 @@ public class Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the involved location/leg
|
* Sets the involved boat
|
||||||
* @param eventLeg the involved leg
|
*
|
||||||
|
* @param eventBoat the involved boat
|
||||||
*/
|
*/
|
||||||
public void setLeg(Leg eventLeg) {
|
public void setBoat(Boat eventBoat) {
|
||||||
this.leg = eventLeg;
|
this.boat = eventBoat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the involved location/leg
|
* Gets the involved location/leg
|
||||||
|
*
|
||||||
* @return the leg involved in the event
|
* @return the leg involved in the event
|
||||||
*/
|
*/
|
||||||
public Leg getLeg() {
|
public Leg getLeg() {
|
||||||
return this.leg;
|
return this.leg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the involved location/leg
|
||||||
|
*
|
||||||
|
* @param eventLeg the involved leg
|
||||||
|
*/
|
||||||
|
public void setLeg(Leg eventLeg) {
|
||||||
|
this.leg = eventLeg;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call when the boat reaches the marker, this will tell the marker the order
|
* Call when the boat reaches the marker, this will tell the marker the order
|
||||||
* in which boats pass it
|
* in which boats pass it
|
||||||
@@ -97,7 +105,6 @@ public class Event {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this event is the boat finishing the race
|
* Returns true if this event is the boat finishing the race
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public boolean getIsFinishingEvent() {
|
public boolean getIsFinishingEvent() {
|
||||||
return this.isFinishingEvent;
|
return this.isFinishingEvent;
|
||||||
@@ -105,6 +112,7 @@ 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 contains the timestamp and course information for this event
|
||||||
*/
|
*/
|
||||||
public String getEventString() {
|
public String getEventString() {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import org.json.simple.JSONObject;
|
|||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -20,7 +20,9 @@ public class FileParser {
|
|||||||
|
|
||||||
private String filePath;
|
private String filePath;
|
||||||
private JSONObject content;
|
private JSONObject content;
|
||||||
/** used to construct an instance of file parser
|
|
||||||
|
/**
|
||||||
|
* used to construct an instance of file parser
|
||||||
*
|
*
|
||||||
* @param filePath a string like path to show location of desired file to
|
* @param filePath a string like path to show location of desired file to
|
||||||
* be parsed
|
* be parsed
|
||||||
@@ -50,6 +52,7 @@ public class FileParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets time scale setting parameter.
|
* Gets time scale setting parameter.
|
||||||
|
*
|
||||||
* @return long time scale. -1 if parameter is invalid (eg. scale is
|
* @return long time scale. -1 if parameter is invalid (eg. scale is
|
||||||
* negative number, or containing non numeric character) or cannot be found.
|
* negative number, or containing non numeric character) or cannot be found.
|
||||||
*/
|
*/
|
||||||
@@ -66,6 +69,7 @@ public class FileParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets race name in the setting file.
|
* Gets race name in the setting file.
|
||||||
|
*
|
||||||
* @return a string of race name. null if race name is invalid or cannot
|
* @return a string of race name. null if race name is invalid or cannot
|
||||||
* be found.
|
* be found.
|
||||||
*/
|
*/
|
||||||
@@ -80,6 +84,7 @@ public class FileParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an array of teams who participate the race.
|
* Gets an array of teams who participate the race.
|
||||||
|
*
|
||||||
* @return an ArrayList containing strings of team names. null if teams
|
* @return an ArrayList containing strings of team names. null if teams
|
||||||
* setting is invalid or there is no team.
|
* setting is invalid or there is no team.
|
||||||
*/
|
*/
|
||||||
@@ -94,6 +99,7 @@ public class FileParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the total number of teams.
|
* Gets the total number of teams.
|
||||||
|
*
|
||||||
* @return the number of teams. 0 if no teams or anything goes wrong.
|
* @return the number of teams. 0 if no teams or anything goes wrong.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -109,6 +115,7 @@ public class FileParser {
|
|||||||
/**
|
/**
|
||||||
* Gets the number of boats that would compete during a race. Returns the
|
* Gets the number of boats that would compete during a race. Returns the
|
||||||
* total number of race size if parameter is invalid or cannot be found.
|
* total number of race size if parameter is invalid or cannot be found.
|
||||||
|
*
|
||||||
* @return an int of the race size.
|
* @return an int of the race size.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ public class Leg {
|
|||||||
private boolean isFinishingLeg;
|
private boolean isFinishingLeg;
|
||||||
private Marker startingMarker;
|
private Marker startingMarker;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Create a new leg
|
* Create a new leg
|
||||||
|
*
|
||||||
@param heading, the magnetic heading of this leg
|
* @param heading, the magnetic heading of this leg
|
||||||
@param distance, the total distance of this leg in meters
|
* @param distance, the total distance of this leg in meters
|
||||||
@param marker, the marker this leg starts on
|
* @param marker, the marker this leg starts on
|
||||||
*/
|
*/
|
||||||
public Leg(int heading, int distance, Marker marker) {
|
public Leg(int heading, int distance, Marker marker) {
|
||||||
this.heading = heading;
|
this.heading = heading;
|
||||||
@@ -20,12 +20,12 @@ public class Leg {
|
|||||||
this.isFinishingLeg = false;
|
this.isFinishingLeg = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Create a new leg
|
* Create a new leg
|
||||||
|
*
|
||||||
@param heading, the magnetic heading of this leg
|
* @param heading, the magnetic heading of this leg
|
||||||
@param distance, the total distance of this leg in meters
|
* @param distance, the total distance of this leg in meters
|
||||||
@param markerName, the name of the marker this leg starts on
|
* @param markerName, the name of the marker this leg starts on
|
||||||
*/
|
*/
|
||||||
public Leg(int heading, int distance, String markerName) {
|
public Leg(int heading, int distance, String markerName) {
|
||||||
this.heading = heading;
|
this.heading = heading;
|
||||||
@@ -34,73 +34,73 @@ public class Leg {
|
|||||||
this.isFinishingLeg = false;
|
this.isFinishingLeg = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Set the heading for this leg
|
* Get the heading of this leg
|
||||||
*/
|
|
||||||
public void setHeading(int heading){
|
|
||||||
this.heading = heading;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Get the heading of this leg
|
|
||||||
*/
|
*/
|
||||||
public int getHeading() {
|
public int getHeading() {
|
||||||
return this.heading;
|
return this.heading;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Set the distance of this leg in meters
|
* Set the heading for this leg
|
||||||
*/
|
*/
|
||||||
public void setDistance(int distance){
|
public void setHeading(int heading) {
|
||||||
this.distance = distance;
|
this.heading = heading;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Get the total distance of this leg in meters
|
* Get the total distance of this leg in meters
|
||||||
*/
|
*/
|
||||||
public int getDistance() {
|
public int getDistance() {
|
||||||
return this.distance;
|
return this.distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Set the marker this leg starts on
|
* Set the distance of this leg in meters
|
||||||
*/
|
*/
|
||||||
public void setMarker(Marker marker){
|
public void setDistance(int distance) {
|
||||||
this.startingMarker = marker;
|
this.distance = distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Returns the marker this leg started on
|
* Returns the marker this leg started on
|
||||||
*/
|
*/
|
||||||
public Marker getMarker() {
|
public Marker getMarker() {
|
||||||
return this.startingMarker;
|
return this.startingMarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Returns the name of the marker this leg started on
|
* Set the marker this leg starts on
|
||||||
|
*/
|
||||||
|
public void setMarker(Marker marker) {
|
||||||
|
this.startingMarker = marker;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the marker this leg started on
|
||||||
*/
|
*/
|
||||||
public String getMarkerLabel() {
|
public String getMarkerLabel() {
|
||||||
return this.startingMarker.getName();
|
return this.startingMarker.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Tell the marker that the boat has passed it
|
* Tell the marker that the boat has passed it
|
||||||
*/
|
*/
|
||||||
public void addBoatToMarker(Boat boat) {
|
public void addBoatToMarker(Boat boat) {
|
||||||
this.startingMarker.addBoat(boat);
|
this.startingMarker.addBoat(boat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Specify whether or not the race finishes on this leg
|
* Specify whether or not the race finishes on this leg
|
||||||
|
*
|
||||||
@param isFinishingLeg whether or not the race finishes on this leg
|
* @param isFinishingLeg whether or not the race finishes on this leg
|
||||||
*/
|
*/
|
||||||
public void setFinishingLeg(boolean isFinishingLeg) {
|
public void setFinishingLeg(boolean isFinishingLeg) {
|
||||||
this.isFinishingLeg = isFinishingLeg;
|
this.isFinishingLeg = isFinishingLeg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
@returns true if this the race finishes after this leg
|
* @returns true if this the race finishes after this leg
|
||||||
*/
|
*/
|
||||||
public boolean getIsFinishingLeg() {
|
public boolean getIsFinishingLeg() {
|
||||||
return this.isFinishingLeg;
|
return this.isFinishingLeg;
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ class Marker{
|
|||||||
this.boatOrder = new ArrayList<Boat>();
|
this.boatOrder = new ArrayList<Boat>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name){
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
public void addBoat(Boat boat) {
|
public void addBoat(Boat boat) {
|
||||||
this.boatOrder.add(boat);
|
this.boatOrder.add(boat);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.*;
|
||||||
|
|
||||||
public class Race {
|
public class Race {
|
||||||
private ArrayList<Boat> boats; // The boats in the race
|
private ArrayList<Boat> boats; // The boats in the race
|
||||||
@@ -36,19 +35,20 @@ public class Race {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Add a boat to the race
|
* Add a boat to the race
|
||||||
@param boat, the boat to add
|
*
|
||||||
|
* @param boat, the boat to add
|
||||||
*/
|
*/
|
||||||
public void addBoat(Boat boat) {
|
public void addBoat(Boat boat) {
|
||||||
boats.add(boat);
|
boats.add(boat);
|
||||||
numberOfBoats += 1;
|
numberOfBoats += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Returns a list of boats in a random order
|
* Returns a list of boats in a random order
|
||||||
|
*
|
||||||
@returns a list of boats
|
* @returns a list of boats
|
||||||
*/
|
*/
|
||||||
public Boat[] getShuffledBoats() {
|
public Boat[] getShuffledBoats() {
|
||||||
// Shuffle the list of boats
|
// Shuffle the list of boats
|
||||||
@@ -58,36 +58,36 @@ public class Race {
|
|||||||
return boats.toArray(new Boat[boats.size()]);
|
return boats.toArray(new Boat[boats.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Returns a list of boats in the order that they
|
* Returns a list of boats in the order that they
|
||||||
finished the race (position 0 is first place)
|
* finished the race (position 0 is first place)
|
||||||
|
*
|
||||||
@returns a list of boats
|
* @returns a list of boats
|
||||||
*/
|
*/
|
||||||
public Boat[] getFinishedBoats() {
|
public Boat[] getFinishedBoats() {
|
||||||
return this.finishingOrder.toArray(new Boat[this.finishingOrder.size()]);
|
return this.finishingOrder.toArray(new Boat[this.finishingOrder.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Returns the number of boats in the race
|
* Returns the number of boats in the race
|
||||||
|
*
|
||||||
@returns the number of boats in the race
|
* @returns the number of boats in the race
|
||||||
*/
|
*/
|
||||||
public int getNumberOfBoats() {
|
public int getNumberOfBoats() {
|
||||||
return numberOfBoats;
|
return numberOfBoats;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Returns a list of boats in the race
|
* Returns a list of boats in the race
|
||||||
|
*
|
||||||
@returns a list of the boats competing in the race
|
* @returns a list of the boats competing in the race
|
||||||
*/
|
*/
|
||||||
public Boat[] getBoats() {
|
public Boat[] getBoats() {
|
||||||
return boats.toArray(new Boat[boats.size()]);
|
return boats.toArray(new Boat[boats.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Prints the order in which the boats finished
|
* Prints the order in which the boats finished
|
||||||
*/
|
*/
|
||||||
public void displayFinishingOrder() {
|
public void displayFinishingOrder() {
|
||||||
int numberOfBoats = this.getNumberOfBoats();
|
int numberOfBoats = this.getNumberOfBoats();
|
||||||
@@ -101,8 +101,8 @@ public class Race {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Prints the list of boats competing in the race
|
* Prints the list of boats competing in the race
|
||||||
*/
|
*/
|
||||||
public void displayStartingBoats() {
|
public void displayStartingBoats() {
|
||||||
int numberOfBoats = this.getNumberOfBoats();
|
int numberOfBoats = this.getNumberOfBoats();
|
||||||
@@ -119,10 +119,10 @@ public class Race {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Adds a leg to the race
|
* Adds a leg to the race
|
||||||
|
*
|
||||||
@param leg, the leg to add to the race
|
* @param leg, the leg to add to the race
|
||||||
*/
|
*/
|
||||||
public void addLeg(Leg leg) {
|
public void addLeg(Leg leg) {
|
||||||
this.legs.add(leg);
|
this.legs.add(leg);
|
||||||
@@ -139,6 +139,7 @@ public class Race {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets time scale
|
* Sets time scale
|
||||||
|
*
|
||||||
* @param timeScale
|
* @param timeScale
|
||||||
*/
|
*/
|
||||||
public void setTimeScale(double timeScale) {
|
public void setTimeScale(double timeScale) {
|
||||||
@@ -208,16 +209,15 @@ public class Race {
|
|||||||
// Wait for 100ms to slow down the while loop
|
// Wait for 100ms to slow down the while loop
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
} catch (java.lang.InterruptedException e) {
|
||||||
catch(java.lang.InterruptedException e){
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Start the race and print each marker with the order
|
* Start the race and print each marker with the order
|
||||||
in which the boats passed that marker
|
* in which the boats passed that marker
|
||||||
*/
|
*/
|
||||||
public void startRace() {
|
public void startRace() {
|
||||||
// record start time.
|
// record start time.
|
||||||
@@ -226,8 +226,8 @@ public class Race {
|
|||||||
iterateEvents();
|
iterateEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Print the order in which the boats passed each marker
|
* Print the order in which the boats passed each marker
|
||||||
*/
|
*/
|
||||||
public void showRaceMarkerResults() {
|
public void showRaceMarkerResults() {
|
||||||
for (Leg leg : this.legs) {
|
for (Leg leg : this.legs) {
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit test for simple App.
|
* Unit test for simple App.
|
||||||
*/
|
*/
|
||||||
public class AppTest
|
public class AppTest {
|
||||||
{
|
|
||||||
@Test
|
@Test
|
||||||
public void testApp()
|
public void testApp() {
|
||||||
{
|
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,22 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit test for the Team class.
|
* Unit test for the Team class.
|
||||||
*/
|
*/
|
||||||
public class BoatTest
|
public class BoatTest {
|
||||||
{
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBoatCreation()
|
public void testBoatCreation() {
|
||||||
{
|
|
||||||
Boat boat1 = new Boat("Team 1");
|
Boat boat1 = new Boat("Team 1");
|
||||||
assertEquals(boat1.getTeamName(), "Team 1");
|
assertEquals(boat1.getTeamName(), "Team 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChangeTeamName()
|
public void testChangeTeamName() {
|
||||||
{
|
|
||||||
Boat boat1 = new Boat("Team 1");
|
Boat boat1 = new Boat("Team 1");
|
||||||
boat1.setTeamName("Team 2");
|
boat1.setTeamName("Team 2");
|
||||||
assertEquals(boat1.getTeamName(), "Team 2");
|
assertEquals(boat1.getTeamName(), "Team 2");
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for Event class
|
* Test for Event class
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package seng302;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/** Unit test for FileParser class
|
/**
|
||||||
|
* Unit test for FileParser class
|
||||||
* Created by Haoming on 5/03/17.
|
* Created by Haoming on 5/03/17.
|
||||||
*/
|
*/
|
||||||
public class FileParserTest {
|
public class FileParserTest {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,8 +14,7 @@ public class LegTest{
|
|||||||
for the marker label
|
for the marker label
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLegCreationUsingMarkerLabel()
|
public void testLegCreationUsingMarkerLabel() {
|
||||||
{
|
|
||||||
Leg leg = new Leg(010, 100, "Marker");
|
Leg leg = new Leg(010, 100, "Marker");
|
||||||
|
|
||||||
assertEquals(leg.getHeading(), 010);
|
assertEquals(leg.getHeading(), 010);
|
||||||
@@ -29,8 +28,7 @@ public class LegTest{
|
|||||||
Marker object
|
Marker object
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLegCreation()
|
public void testLegCreation() {
|
||||||
{
|
|
||||||
Leg leg = new Leg(010, 100, new Marker("Marker"));
|
Leg leg = new Leg(010, 100, new Marker("Marker"));
|
||||||
|
|
||||||
assertEquals(leg.getHeading(), 010);
|
assertEquals(leg.getHeading(), 010);
|
||||||
@@ -44,8 +42,7 @@ public class LegTest{
|
|||||||
leg is the finishing leg
|
leg is the finishing leg
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSetFinishLeg()
|
public void testSetFinishLeg() {
|
||||||
{
|
|
||||||
Leg leg = new Leg(010, 100, "Marker");
|
Leg leg = new Leg(010, 100, "Marker");
|
||||||
|
|
||||||
leg.setFinishingLeg(true);
|
leg.setFinishingLeg(true);
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit test for the Race class.
|
* Unit test for the Race class.
|
||||||
*/
|
*/
|
||||||
public class RaceTest
|
public class RaceTest {
|
||||||
{
|
/**
|
||||||
/*
|
* Test that all boats were added to the race
|
||||||
Test that all boats were added to the race
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testAddingBoatsToRace() {
|
public void testAddingBoatsToRace() {
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
{
|
{
|
||||||
"time-scale": "abc",
|
"time-scale": "abc",
|
||||||
"race-name": 123,
|
"race-name": 123,
|
||||||
"teams-with-wrong-name":["team1","team2","team3"]
|
"teams-with-wrong-name": [
|
||||||
|
"team1",
|
||||||
|
"team2",
|
||||||
|
"team3"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@@ -3,11 +3,29 @@
|
|||||||
"time-scale": 1,
|
"time-scale": 1,
|
||||||
"race-size": 2,
|
"race-size": 2,
|
||||||
"teams": [
|
"teams": [
|
||||||
{"team-name": "Oracle Team USA", "velocity": 20.9},
|
{
|
||||||
{"team-name": "Artemis Racing", "velocity": 18.3},
|
"team-name": "Oracle Team USA",
|
||||||
{"team-name": "Emirates Team New Zealand", "velocity": 21.5},
|
"velocity": 20.9
|
||||||
{"team-name": "Groupama Team France","velocity": 19.9},
|
},
|
||||||
{"team-name": "Land Rover BAR", "velocity": 17.6},
|
{
|
||||||
{"team-name": "SoftBank Team Japan", "velocity": 16.6}
|
"team-name": "Artemis Racing",
|
||||||
|
"velocity": 18.3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"team-name": "Emirates Team New Zealand",
|
||||||
|
"velocity": 21.5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"team-name": "Groupama Team France",
|
||||||
|
"velocity": 19.9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"team-name": "Land Rover BAR",
|
||||||
|
"velocity": 17.6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"team-name": "SoftBank Team Japan",
|
||||||
|
"velocity": 16.6
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user