@Test public void TestCloseDriver() { assertTrue(cs.isNearby(results.get(0), new RaceSimulationResult(results, false), 50)); }
public boolean isNearby(CarSimulationResult carResult, RaceSimulationResult raceResult, double distance) { final Predicate<CarSimulationResult> close = res -> Math.abs(carResult.getDistanceTraveled() - res.getDistanceTraveled()) < distance; final Predicate<CarSimulationResult> self = res -> !res.getConfiguration().getCar().equals(configuration.getCar()); return raceResult.getResults().stream().anyMatch(self.and(close)); }
CarSimulator { public boolean isNearby(CarSimulationResult carResult, RaceSimulationResult raceResult, double distance) { final Predicate<CarSimulationResult> close = res -> Math.abs(carResult.getDistanceTraveled() - res.getDistanceTraveled()) < distance; final Predicate<CarSimulationResult> self = res -> !res.getConfiguration().getCar().equals(configuration.getCar()); return raceResult.getResults().stream().anyMatch(self.and(close)); } }
CarSimulator { public boolean isNearby(CarSimulationResult carResult, RaceSimulationResult raceResult, double distance) { final Predicate<CarSimulationResult> close = res -> Math.abs(carResult.getDistanceTraveled() - res.getDistanceTraveled()) < distance; final Predicate<CarSimulationResult> self = res -> !res.getConfiguration().getCar().equals(configuration.getCar()); return raceResult.getResults().stream().anyMatch(self.and(close)); } CarSimulator(CarConfiguration configuration, CarParameters parameters); }
CarSimulator { public boolean isNearby(CarSimulationResult carResult, RaceSimulationResult raceResult, double distance) { final Predicate<CarSimulationResult> close = res -> Math.abs(carResult.getDistanceTraveled() - res.getDistanceTraveled()) < distance; final Predicate<CarSimulationResult> self = res -> !res.getConfiguration().getCar().equals(configuration.getCar()); return raceResult.getResults().stream().anyMatch(self.and(close)); } 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 boolean isNearby(CarSimulationResult carResult, RaceSimulationResult raceResult, double distance) { final Predicate<CarSimulationResult> close = res -> Math.abs(carResult.getDistanceTraveled() - res.getDistanceTraveled()) < distance; final Predicate<CarSimulationResult> self = res -> !res.getConfiguration().getCar().equals(configuration.getCar()); return raceResult.getResults().stream().anyMatch(self.and(close)); } 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);  }