Skip to content

Instantly share code, notes, and snippets.

@Arbow
Created June 23, 2009 09:46
Show Gist options
  • Save Arbow/134456 to your computer and use it in GitHub Desktop.
Save Arbow/134456 to your computer and use it in GitHub Desktop.
/**
* 根据概率产生相应奖品
*
* @return 相应对应的号码
*/
@SuppressWarnings("unchecked")
public static int getAward() {
Map result = new LinkedHashMap();
for (int i = 0; i < 500; i++) {
result.put("" + i, "" + 0);
}
for (int i = 500; i < 500 + 250; i++) {
result.put("" + i, "" + 1);
}
for (int i = 500 + 250; i < 500 + 250 + 128; i++) {
result.put("" + i, "" + 2);
}
for (int i = 500 + 250 + 128; i < 500 + 250 + 128 + 100; i++) {
result.put("" + i, "" + 3);
}
for (int i = 500 + 250 + 128 + 100; i < 500 + 250 + 128 + 100 + 20; i++) {
result.put("" + i, "" + 4);
}
for (int i = 500 + 250 + 128 + 100 + 20; i < 500 + 250 + 128 + 100 + 20 + 2; i++) {
result.put("" + i, "" + 5);
}
String reState = result.get("" + (int) (Math.random() * 1000)) + "";
return Integer.parseInt(reState);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment