@Test public void GetMaxDistance() { setUp(); double temp = 0; Random random = new Random(1); for (int i = 0; i < 100000; i++) { temp += cs.calculateDelta(random); } assertEquals(718.6285499929213, temp/100000, delta); }
public double calculateDelta(Random random) { double mechFactor = configuration.getMechanic() .getSpecialistFactor(parameters.getMechanicalRisk()); double aeroFactor = configuration.getAerodynamicist() .getSpecialistFactor(parameters.getAerodynamicRisk()); double stratFactor = configuration.getStrategist() .getSpecialistFactor(parameters.getStrategicRisk()) * configuration.getDriver().getStrategy(); double driverFactor = configuration.getDriver().getDriverFactor(); double maxDistance = configuration.getEngine().getMaxDistance(parameters.getTire()); return random.nextDouble() * mechFactor * aeroFactor * stratFactor * driverFactor * maxDistance; }
CarSimulator { public double calculateDelta(Random random) { double mechFactor = configuration.getMechanic() .getSpecialistFactor(parameters.getMechanicalRisk()); double aeroFactor = configuration.getAerodynamicist() .getSpecialistFactor(parameters.getAerodynamicRisk()); double stratFactor = configuration.getStrategist() .getSpecialistFactor(parameters.getStrategicRisk()) * configuration.getDriver().getStrategy(); double driverFactor = configuration.getDriver().getDriverFactor(); double maxDistance = configuration.getEngine().getMaxDistance(parameters.getTire()); return random.nextDouble() * mechFactor * aeroFactor * stratFactor * driverFactor * maxDistance; } }
CarSimulator { public double calculateDelta(Random random) { double mechFactor = configuration.getMechanic() .getSpecialistFactor(parameters.getMechanicalRisk()); double aeroFactor = configuration.getAerodynamicist() .getSpecialistFactor(parameters.getAerodynamicRisk()); double stratFactor = configuration.getStrategist() .getSpecialistFactor(parameters.getStrategicRisk()) * configuration.getDriver().getStrategy(); double driverFactor = configuration.getDriver().getDriverFactor(); double maxDistance = configuration.getEngine().getMaxDistance(parameters.getTire()); return random.nextDouble() * mechFactor * aeroFactor * stratFactor * driverFactor * maxDistance; } CarSimulator(CarConfiguration configuration, CarParameters parameters); }
CarSimulator { public double calculateDelta(Random random) { double mechFactor = configuration.getMechanic() .getSpecialistFactor(parameters.getMechanicalRisk()); double aeroFactor = configuration.getAerodynamicist() .getSpecialistFactor(parameters.getAerodynamicRisk()); double stratFactor = configuration.getStrategist() .getSpecialistFactor(parameters.getStrategicRisk()) * configuration.getDriver().getStrategy(); double driverFactor = configuration.getDriver().getDriverFactor(); double maxDistance = configuration.getEngine().getMaxDistance(parameters.getTire()); return random.nextDouble() * mechFactor * aeroFactor * stratFactor * driverFactor * maxDistance; } CarSimulator(CarConfiguration configuration, CarParameters parameters); CarConfiguration getConfiguration(); void setConfiguration(CarConfiguration configuration); CarParameters getParameters(); void setParameters(CarParameters parameters); double calculateDelta(Random random); boolean hasCrashed(boolean raining, boolean nearby, Random random); boolean isNearby(CarSimulationResult carResult, RaceSimulationResult raceResult,
                            double distance); }
CarSimulator { public double calculateDelta(Random random) { double mechFactor = configuration.getMechanic() .getSpecialistFactor(parameters.getMechanicalRisk()); double aeroFactor = configuration.getAerodynamicist() .getSpecialistFactor(parameters.getAerodynamicRisk()); double stratFactor = configuration.getStrategist() .getSpecialistFactor(parameters.getStrategicRisk()) * configuration.getDriver().getStrategy(); double driverFactor = configuration.getDriver().getDriverFactor(); double maxDistance = configuration.getEngine().getMaxDistance(parameters.getTire()); return random.nextDouble() * mechFactor * aeroFactor * stratFactor * driverFactor * maxDistance; } CarSimulator(CarConfiguration configuration, CarParameters parameters); CarConfiguration getConfiguration(); void setConfiguration(CarConfiguration configuration); CarParameters getParameters(); void setParameters(CarParameters parameters); double calculateDelta(Random random); boolean hasCrashed(boolean raining, boolean nearby, Random random); boolean isNearby(CarSimulationResult carResult, RaceSimulationResult raceResult,
                            double distance);  }