标签:
for (int j = 0; j < 100; j++) { List<Prize> prizes = prizeManager.findAll(); double randomNumber; randomNumber = Math.random(); for (int i = 0; i < prizes.size(); i++) { float start = 0; float end = 0; if(i==0){ start = 0; end = (end + prizes.get(i).getWinningRate()); } for (int k = 0; k < i; k++) { start += prizes.get(k).getWinningRate(); end = (start+ prizes.get(k+1).getWinningRate()); } double st = start / 100; double en = end / 100; /*System.out.println(randomNumber >= st ); System.out.println(randomNumber <= en );*/ if (randomNumber >= st && randomNumber <= en ) { System.out.println(prizes.get(i).getPrizeName()); // return prizes.get(i).getPrizeName(); } } }
标签:
原文地址:http://www.cnblogs.com/yaoyao66123/p/4576397.html