You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.6 KiB
56 lines
1.6 KiB
package seng302.Model;
|
|
|
|
import seng302.Controllers.RaceController;
|
|
import seng302.GPSCoordinate;
|
|
import seng302.GraphCoordinate;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
/**
|
|
* Created by cbt24 on 6/03/17.
|
|
*/
|
|
public class ConstantVelocityRace extends Race {
|
|
/**
|
|
* Initialiser for a Race with constant velocity.
|
|
* @param startingBoats array of boats
|
|
* @param marks array of RaceMarkers that the boats need to pass in order to finish the course.
|
|
* @see Boat
|
|
* @see Leg
|
|
*/
|
|
|
|
public ConstantVelocityRace(BoatInRace[] startingBoats, ArrayList<Leg> marks, RaceController controller) {
|
|
super(startingBoats, marks, controller);
|
|
}
|
|
|
|
public ConstantVelocityRace(BoatInRace[] startingBoats, ArrayList<Leg> marks) {
|
|
super(startingBoats, marks);
|
|
}
|
|
|
|
protected void updatePosition(BoatInRace boat, int millisecondsElapsed) {
|
|
|
|
//distanceTravelled = velocity (nm p hr) * time taken to update loop
|
|
double distanceTravelled = boat.getVelocity() * millisecondsElapsed/3600000;
|
|
double totalDistanceTravelled = distanceTravelled + boat.getDistanceTravelledInLeg();
|
|
|
|
boat.setDistanceTravelledInLeg(totalDistanceTravelled);
|
|
boat.setCurrentPosition(calculate_position(totalDistanceTravelled, boat.calculateHeading()));
|
|
//Calculate new coordinates based on boat's heading for the leg, and distance traveled
|
|
}
|
|
|
|
protected GPSCoordinate calculate_position(double distanceTravelled, double heading) {
|
|
|
|
//Find new coordinate using current heading and distance
|
|
|
|
return new GPSCoordinate(-1, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|