@Test public void randomNumber_shouldBeEqualToOrGreaterThanMin() { int numberOfTests = 100; for (int i = 0; i < numberOfTests; i++) { double randVolume = volumeLevelGenerator.generateRandomDecibleLevel(-9999, 5); assertThat(randVolume).isGreaterThanOrEqualTo(1); assertThat(randVolume).isLessThanOrEqualTo(15); } }
public double generateRandomDecibleLevel(int min, int max){ if(min < 1){ min = 1; } if(max > DB_RANGE){ max = DB_RANGE; } if(min > max){ max = min; } Random random = new Random(); return 1.0 * (double)random.nextInt(max - min + 1) + min; }
VolumeLevelGenerator { public double generateRandomDecibleLevel(int min, int max){ if(min < 1){ min = 1; } if(max > DB_RANGE){ max = DB_RANGE; } if(min > max){ max = min; } Random random = new Random(); return 1.0 * (double)random.nextInt(max - min + 1) + min; } }
VolumeLevelGenerator { public double generateRandomDecibleLevel(int min, int max){ if(min < 1){ min = 1; } if(max > DB_RANGE){ max = DB_RANGE; } if(min > max){ max = min; } Random random = new Random(); return 1.0 * (double)random.nextInt(max - min + 1) + min; }  }
VolumeLevelGenerator { public double generateRandomDecibleLevel(int min, int max){ if(min < 1){ min = 1; } if(max > DB_RANGE){ max = DB_RANGE; } if(min > max){ max = min; } Random random = new Random(); return 1.0 * (double)random.nextInt(max - min + 1) + min; }  List<Map<String, Double>> generatePotentialMixes(); Map<String, Double> generatePotentialMix(); double generateRandomDecibleLevel(int min, int max); }
VolumeLevelGenerator { public double generateRandomDecibleLevel(int min, int max){ if(min < 1){ min = 1; } if(max > DB_RANGE){ max = DB_RANGE; } if(min > max){ max = min; } Random random = new Random(); return 1.0 * (double)random.nextInt(max - min + 1) + min; }  List<Map<String, Double>> generatePotentialMixes(); Map<String, Double> generatePotentialMix(); double generateRandomDecibleLevel(int min, int max); final int DB_RANGE; final int NUM_OF_MIXES; }