diff --git a/src/main/java/seng302/models/App.java b/src/main/java/seng302/models/App.java index 4cecb733..6601ee4e 100644 --- a/src/main/java/seng302/models/App.java +++ b/src/main/java/seng302/models/App.java @@ -55,7 +55,7 @@ public class App { } race.addLeg(new Leg(35, 100, "Start")); - race.addLeg(new Leg(10, 300, "Marker 1")); + race.addLeg(new Leg(10, 300, "Mark 1")); race.addLeg(new Leg(350, 400, "Leeward Gate")); race.addLeg(new Leg(10, 400, "Windward Gate")); diff --git a/src/main/java/seng302/models/GateMark.java b/src/main/java/seng302/models/GateMark.java new file mode 100644 index 00000000..c37e84f4 --- /dev/null +++ b/src/main/java/seng302/models/GateMark.java @@ -0,0 +1,20 @@ +package seng302.models; + +/** + * Created by ptg19 on 16/03/17. + */ +public class GateMark { + private double lat; + private double lon; + private Mark mark1; + private Mark mark2; + private String name; + + public GateMark(String name, Mark mark1, Mark mark2, double lat, double lon){ + this.lat = lat; + this.lon = lon; + this.mark1 = mark1; + this.mark2 = mark2; + this.name = name; + } +} diff --git a/src/main/java/seng302/models/Leg.java b/src/main/java/seng302/models/Leg.java index 97c776e3..4d42b48f 100644 --- a/src/main/java/seng302/models/Leg.java +++ b/src/main/java/seng302/models/Leg.java @@ -7,19 +7,19 @@ public class Leg { private int heading; private int distance; private boolean isFinishingLeg; - private Marker startingMarker; + private Mark startingMark; /** * Create a new leg * * @param heading, the magnetic heading of this leg * @param distance, the total distance of this leg in meters - * @param marker, the marker this leg starts on + * @param mark, the mark this leg starts on */ - public Leg(int heading, int distance, Marker marker) { + public Leg(int heading, int distance, Mark mark) { this.heading = heading; this.distance = distance; - this.startingMarker = marker; + this.startingMark = mark; this.isFinishingLeg = false; } @@ -33,7 +33,7 @@ public class Leg { public Leg(int heading, int distance, String markerName) { this.heading = heading; this.distance = distance; - this.startingMarker = new Marker(markerName); + this.startingMark = new Mark(markerName); this.isFinishingLeg = false; } @@ -68,29 +68,29 @@ public class Leg { /** * Returns the marker this leg started on */ - public Marker getMarker() { - return this.startingMarker; + public Mark getMarker() { + return this.startingMark; } /** - * Set the marker this leg starts on + * Set the mark this leg starts on */ - public void setMarker(Marker marker) { - this.startingMarker = marker; + public void setMarker(Mark mark) { + this.startingMark = mark; } /** * Returns the name of the marker this leg started on */ public String getMarkerLabel() { - return this.startingMarker.getName(); + return this.startingMark.getName(); } /** * Tell the marker that the boat has passed it */ public void addBoatToMarker(Boat boat) { - this.startingMarker.addBoat(boat); + this.startingMark.addBoat(boat); } /** diff --git a/src/main/java/seng302/models/Marker.java b/src/main/java/seng302/models/Mark.java similarity index 57% rename from src/main/java/seng302/models/Marker.java rename to src/main/java/seng302/models/Mark.java index 6c70b2f3..27faec81 100644 --- a/src/main/java/seng302/models/Marker.java +++ b/src/main/java/seng302/models/Mark.java @@ -5,7 +5,9 @@ import java.util.ArrayList; /** * Represents the marker at the beginning of a leg */ -public class Marker{ +public class Mark { + private double lat; + private double lon; private String name; private ArrayList boatOrder; @@ -14,43 +16,22 @@ public class Marker{ * * @param name, the name of the marker */ - public Marker(String name){ + public Mark(String name, double lat, double lon){ this.name = name; + this.lat = lat; + this.lon = lon; this.boatOrder = new ArrayList(); } - /** - * Set the name of the marker - * - * @param name, the name of the marker - */ public void setName(String name){ this.name = name; } - - /** - * Get the name of the marker - * - * @return the name of the marker - */ public String getName(){ return this.name; } - - /** - * Add a boat as they pass the marker - * - * @param boat, the boat that passed the marker - */ public void addBoat(Boat boat){ this.boatOrder.add(boat); } - - /** - * Get a list of boats in the order they passed the marker - * - * @return An array of boats in the order they passed the marker - */ public Boat[] getBoats(){ return this.boatOrder.toArray(new Boat[this.boatOrder.size()]); } diff --git a/src/test/java/seng302/LegTest.java b/src/test/java/seng302/LegTest.java index 5af01db8..23d86d7f 100644 --- a/src/test/java/seng302/LegTest.java +++ b/src/test/java/seng302/LegTest.java @@ -2,7 +2,7 @@ package seng302; import org.junit.Test; import seng302.models.Leg; -import seng302.models.Marker; +import seng302.models.Mark; import static org.junit.Assert.assertEquals; @@ -17,25 +17,25 @@ public class LegTest { */ @Test public void testLegCreationUsingMarkerLabel() { - Leg leg = new Leg(010, 100, "Marker"); + Leg leg = new Leg(010, 100, "Mark"); assertEquals(leg.getHeading(), 010); assertEquals(leg.getDistance(), 100); - assertEquals(leg.getMarkerLabel(), "Marker"); + assertEquals(leg.getMarkerLabel(), "Mark"); assertEquals(leg.getIsFinishingLeg(), false); } /** * Test creation of the leg by providing a - * Marker object + * Mark object */ @Test public void testLegCreation() { - Leg leg = new Leg(010, 100, new Marker("Marker")); + Leg leg = new Leg(010, 100, new Mark("Mark")); assertEquals(leg.getHeading(), 010); assertEquals(leg.getDistance(), 100); - assertEquals(leg.getMarkerLabel(), "Marker"); + assertEquals(leg.getMarkerLabel(), "Mark"); assertEquals(leg.getIsFinishingLeg(), false); } @@ -45,7 +45,7 @@ public class LegTest { */ @Test public void testSetFinishLeg() { - Leg leg = new Leg(010, 100, "Marker"); + Leg leg = new Leg(010, 100, "Mark"); leg.setFinishingLeg(true); assertEquals(leg.getIsFinishingLeg(), true);