mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Fixed incorrect headings and velocity display location
- Velocity is now shown in the list of starting boats #fix - Headings have been corrected Tags: #fix
This commit is contained in:
@@ -39,12 +39,12 @@ public class App
|
||||
race.addBoat(new Boat(boatNames.get(i), (Double)(teams.get(i).get("velocity"))));
|
||||
}
|
||||
|
||||
race.addLeg(new Leg(035, 100, "Start"));
|
||||
race.addLeg(new Leg(010, 300, "Marker 1"));
|
||||
race.addLeg(new Leg(35, 100, "Start"));
|
||||
race.addLeg(new Leg(10, 300, "Marker 1"));
|
||||
race.addLeg(new Leg(350, 400, "Leeward Gate"));
|
||||
race.addLeg(new Leg(010, 400, "Windward Gate"));
|
||||
race.addLeg(new Leg(10, 400, "Windward Gate"));
|
||||
|
||||
Leg finishingLeg = new Leg(010, 400, "Leeward Gate");
|
||||
Leg finishingLeg = new Leg(10, 400, "Leeward Gate");
|
||||
finishingLeg.setFinishingLeg(true);
|
||||
|
||||
race.addLeg(finishingLeg);
|
||||
|
||||
@@ -16,6 +16,7 @@ public class Event {
|
||||
private long time;
|
||||
private Boat boat;
|
||||
private Leg leg;
|
||||
private boolean isFinishingEvent = false;
|
||||
|
||||
public Event(long eventTime, Boat eventBoat, Leg eventLeg) {
|
||||
this.time = eventTime;
|
||||
@@ -23,6 +24,13 @@ public class Event {
|
||||
this.leg = eventLeg;
|
||||
}
|
||||
|
||||
public Event(long eventTime, Boat eventBoat, Leg eventLeg, boolean isFinishingEvent) {
|
||||
this.time = eventTime;
|
||||
this.boat = eventBoat;
|
||||
this.leg = eventLeg;
|
||||
this.isFinishingEvent = isFinishingEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time for the event
|
||||
* @param eventTime the time for event in millisecond
|
||||
@@ -87,6 +95,14 @@ public class Event {
|
||||
this.leg.addBoatToMarker(boat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this event is the boat finishing the race
|
||||
*
|
||||
*/
|
||||
public boolean getIsFinishingEvent(){
|
||||
return this.isFinishingEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -94,6 +110,10 @@ public class Event {
|
||||
public String getEventString(){
|
||||
String currentHeading = Integer.toString(this.getLeg().getHeading());
|
||||
|
||||
if (this.isFinishingEvent){
|
||||
return (this.getTimeString() + ", " + this.getBoat().getTeamName() + " finished the race");
|
||||
}
|
||||
|
||||
return (this.getTimeString() + ", " + this.getBoat().getTeamName() + " passed " + this.getLeg().getMarkerLabel() + " going heading " + currentHeading + "°");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,6 +158,13 @@ public class Race {
|
||||
Event event = new Event(time, boat, leg);
|
||||
events.add(event);
|
||||
totalDistance += leg.getDistance();
|
||||
|
||||
// If finishing leg, add another event for when the boat finishes the race
|
||||
if (leg.getIsFinishingLeg()){
|
||||
time = (long) (1000 * totalDistance / boat.getVelocity());
|
||||
event = new Event(time, boat, leg, true);
|
||||
events.add(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,7 +200,7 @@ public class Race {
|
||||
System.out.println(nextEvent.getEventString());
|
||||
nextEvent.addBoatToMarker();
|
||||
|
||||
if (nextEvent.getLeg().getIsFinishingLeg()){
|
||||
if (nextEvent.getIsFinishingEvent()){
|
||||
this.finishingOrder.add(nextEvent.getBoat());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user