Added gate mark and refactored marker to mark #story[378]

This commit is contained in:
Peter
2017-03-16 16:11:48 +13:00
parent 550812d8e1
commit 11c5e1e9ba
5 changed files with 46 additions and 45 deletions
+1 -1
View File
@@ -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"));
@@ -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;
}
}
+12 -12
View File
@@ -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);
}
/**
@@ -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<Boat> 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<Boat>();
}
/**
* 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()]);
}