Added abbreviations to each boat
-BoatInRace now takes extra parameter "abbrev" #story [18]
This commit is contained in:
@@ -25,12 +25,12 @@ public class Constants {
|
||||
public static final GPSCoordinate finishLineMarker2 = new GPSCoordinate(32.317257, -64.836260);
|
||||
|
||||
public static final BoatInRace[] OFFICIAL_AC35_COMPETITORS = new BoatInRace[]
|
||||
{new BoatInRace("Oracle Team USA", 200.0, Color.BLUEVIOLET),
|
||||
new BoatInRace("Land Rover BAR", 180.0, Color.BLACK),
|
||||
new BoatInRace("SoftBank Team Japan", 190.0, Color.RED),
|
||||
new BoatInRace("Groupama Team France", 210.0, Color.ORANGE),
|
||||
new BoatInRace("Artemis Racing", 220.0, Color.DARKOLIVEGREEN),
|
||||
new BoatInRace("Emirates Team New Zealand", 310, Color.LIMEGREEN)};
|
||||
{new BoatInRace("Oracle Team USA", 200.0, Color.BLUEVIOLET, "USA"),
|
||||
new BoatInRace("Land Rover BAR", 180.0, Color.BLACK, "BAR"),
|
||||
new BoatInRace("SoftBank Team Japan", 190.0, Color.RED, "JAP"),
|
||||
new BoatInRace("Groupama Team France", 210.0, Color.ORANGE, "FRN"),
|
||||
new BoatInRace("Artemis Racing", 220.0, Color.DARKOLIVEGREEN, "ART"),
|
||||
new BoatInRace("Emirates Team New Zealand", 310, Color.LIMEGREEN, "ENZ")};
|
||||
|
||||
//public static final Leg bermudaCourseStartToMark1 = new Leg(0, , new )
|
||||
}
|
||||
|
||||
@@ -8,15 +8,17 @@ import java.util.ArrayList;
|
||||
public class Boat {
|
||||
private String name;
|
||||
private double velocity;
|
||||
private String abbrev;
|
||||
|
||||
/**
|
||||
* Boat initialiser which keeps all of the information of the boat.
|
||||
* @param name Name of the Boat.
|
||||
* @param velocity Speed in m/s that the boat travels at.
|
||||
*/
|
||||
public Boat(String name, double velocity){
|
||||
public Boat(String name, double velocity, String abbrev){
|
||||
this.velocity = velocity;
|
||||
this.name = name;
|
||||
this.abbrev = abbrev;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,4 +45,6 @@ public class Boat {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public String getAbbrev() { return abbrev; }
|
||||
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ public class BoatInRace extends Boat {
|
||||
* @param velocity Speed that the boat travels.
|
||||
* @param colour Colour the boat will be displayed as on the map
|
||||
*/
|
||||
public BoatInRace(String name, double velocity, Color colour) {
|
||||
super(name, velocity);
|
||||
public BoatInRace(String name, double velocity, Color colour, String abbrev) {
|
||||
super(name, velocity, abbrev);
|
||||
setColour(colour);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public abstract class Race implements Runnable {
|
||||
protected long totalTimeElapsed;
|
||||
|
||||
|
||||
private int SLEEP_TIME = 25; //time in milliseconds to pause in a paced loop
|
||||
private int SLEEP_TIME = 50; //time in milliseconds to pause in a paced loop
|
||||
private int PRERACE_TIME = 10000;//Integer.MAX_VALUE; //time in milliseconds to pause during pre-race
|
||||
|
||||
/**
|
||||
|
||||
@@ -126,11 +126,12 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
|
||||
/**
|
||||
* Display given name and speed of boat at a graph coordinate
|
||||
* @param name name of boat
|
||||
* @param name name of the boat
|
||||
* @param speed speed of the boat
|
||||
* @param coordinate coordinate the text appears
|
||||
*/
|
||||
public void displayText(String name, double speed, GraphCoordinate coordinate){
|
||||
String text = name + ", " + speed + " knots";
|
||||
String text = name + ", " + speed + " knots";
|
||||
gc.fillText(text, coordinate.getX()+20, coordinate.getY());
|
||||
}
|
||||
|
||||
@@ -143,7 +144,7 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
double height = getHeight();
|
||||
|
||||
gc.clearRect(0, 0, width, height);
|
||||
System.out.println("Race Map Canvas Width: "+ width + ", Height:" + height);
|
||||
//System.out.println("Race Map Canvas Width: "+ width + ", Height:" + height);
|
||||
this.map = new RaceMap(32.278, -64.863, 32.320989, -64.821, (int)width, (int)height);
|
||||
|
||||
if (map == null){
|
||||
@@ -176,7 +177,7 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
if (boat != null) {
|
||||
// System.out.print("Drawing Boat At: " + boat.getCurrentPosition());
|
||||
displayMark(this.map.convertGPS(boat.getCurrentPosition()), boat.getColour());
|
||||
displayText(boat.getName(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()));
|
||||
displayText(boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user