Implemented Color Enum & boat will call function from enum to get next color. Using static colour cycling for now.

#story[377]
This commit is contained in:
Ryan Tan
2017-03-17 00:57:50 +13:00
parent 0039703f03
commit 44d4f25413
3 changed files with 73 additions and 0 deletions
+8
View File
@@ -1,5 +1,7 @@
package seng302.models;
import javafx.scene.paint.Color;
/**
* Represents a boat in the race.
*/
@@ -10,6 +12,7 @@ public class Boat {
private double lat; // Boats position
private double lon; // -
private double distanceToNextMark;
private Color color;
public Boat(String teamName) {
this.teamName = teamName;
@@ -17,6 +20,7 @@ public class Boat {
this.lat = 0.0;
this.lon = 0.0;
this.distanceToNextMark = 0.0;
this.color = Colors.getColor();
}
/**
@@ -89,4 +93,8 @@ public class Boat {
public double getLongitude(){
return this.lon;
}
public Color getColor() {
return color;
}
}
+20
View File
@@ -0,0 +1,20 @@
package seng302.models;
import javafx.scene.paint.Color;
/**
* Created by ryan_ on 16/03/2017.
*/
public enum Colors {
RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE;
static Integer index = 0;
public static Color getColor() {
index++;
if (index > 6) {
index = 1;
}
return Color.valueOf(values()[index-1].toString());
}
}