Merged wind generator into this branch. #story[1094]

main
Joseph Gardner 8 years ago
parent 51bbdf9a50
commit fba256113a

@ -47,7 +47,10 @@ public class MockRace extends Race {
*/ */
private int scaleFactor; private int scaleFactor;
/**
* Object used to generate changes in wind speed/direction.
*/
private WindGenerator windGenerator;
/** /**

@ -1,92 +0,0 @@
package mock.model;
import shared.model.Bearing;
import java.util.Random;
public class Wind {
/**
* Used to generate random numbers when changing the wind direction.
*/
private int changeWind = 4;
/**
* The bearing the wind direction starts at.
*/
private Bearing windBearing;
/**
* The lower bearing angle that the wind may have.
*/
private Bearing windLowerBound;
/**
* The upper bearing angle that the wind may have.
*/
private Bearing windUpperBound;
double windSpeed;
public Wind() {
this.windBearing = Bearing.fromDegrees(225);
this.windSpeed = 12;
this.windLowerBound = Bearing.fromDegrees(215);
this.windUpperBound = Bearing.fromDegrees(235);
}
public Wind(Bearing windBearing, double windSpeed, Bearing windLowerBound, Bearing windUpperBound) {
this.windBearing = windBearing;
this.windSpeed = windSpeed;
this.windLowerBound = windLowerBound;
this.windUpperBound = windUpperBound;
}
/**
* Changes the wind direction randomly, while keeping it within [windLowerBound, windUpperBound].
*/
public void changeWindDirection() {
//Randomly add or remove 0.5 degrees.
int r = new Random().nextInt(changeWind) + 1;
if (r == 1) {
//Add 0.5 degrees to the wind bearing.
this.windBearing.setDegrees(this.windBearing.degrees() + 0.5);
} else if (r == 2) {
//Minus 0.5 degrees from the wind bearing.
this.windBearing.setDegrees(this.windBearing.degrees() - 0.5);
}
//Ensure that the wind is in the correct bounds.
if (this.windBearing.degrees() > this.windUpperBound.degrees()) {
this.windBearing.setBearing(this.windUpperBound);
} else if (this.windBearing.degrees() < this.windLowerBound.degrees()) {
this.windBearing.setBearing(this.windLowerBound);
}
}
public Bearing getWindDirection() {
return this.windBearing;
}
public double getWindSpeed() {
return this.windSpeed;
}
public void setWindDirection(Bearing windBearing) {
this.windBearing = windBearing;
}
public void setWindSpeed(double windSpeed) {
this.windSpeed = windSpeed;
}
public void setDegrees(double degrees) {
this.windBearing.setDegrees(degrees);
}
}
Loading…
Cancel
Save