From fba256113a7acccba09bc808d50a49a89729b068 Mon Sep 17 00:00:00 2001 From: Joseph Gardner Date: Wed, 2 Aug 2017 15:09:59 +1200 Subject: [PATCH] Merged wind generator into this branch. #story[1094] --- .../src/main/java/mock/model/MockRace.java | 5 +- .../src/main/java/mock/model/Wind.java | 92 ------------------- 2 files changed, 4 insertions(+), 93 deletions(-) delete mode 100644 racevisionGame/src/main/java/mock/model/Wind.java diff --git a/racevisionGame/src/main/java/mock/model/MockRace.java b/racevisionGame/src/main/java/mock/model/MockRace.java index 845b00a6..78ce44b2 100644 --- a/racevisionGame/src/main/java/mock/model/MockRace.java +++ b/racevisionGame/src/main/java/mock/model/MockRace.java @@ -47,7 +47,10 @@ public class MockRace extends Race { */ private int scaleFactor; - + /** + * Object used to generate changes in wind speed/direction. + */ + private WindGenerator windGenerator; /** diff --git a/racevisionGame/src/main/java/mock/model/Wind.java b/racevisionGame/src/main/java/mock/model/Wind.java deleted file mode 100644 index 199cb98b..00000000 --- a/racevisionGame/src/main/java/mock/model/Wind.java +++ /dev/null @@ -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); - } -}