這篇文章主要介紹java如何實現(xiàn)的根據(jù)概率隨機(jī)中獎測試類,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯(lián)是一家專業(yè)提供運河企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計、H5頁面制作、小程序制作等業(yè)務(wù)。10年已為運河眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站制作公司優(yōu)惠進(jìn)行中。
具體如下:
最近要做一個寶箱抽獎的功能 自己先聯(lián)系了一下,分別用 list和set 進(jìn)行存儲和抽取,做了一個時間消耗的對比,感覺list應(yīng)該比set讀取的要快些,但是這也不一定,希望大家能夠共同討論。
廢話少說上代碼:
package com.test.testRandom; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Random; import java.util.Set; /** 根據(jù)概率獲取獎品的測試類 */ public class TestRandom { public static void main(String[] args) { TestRandom tr = new TestRandom(); // 用List隨機(jī) long begin = System.currentTimeMillis(); for (int i = 0; i < 100; i++) { tr.getGumByList(); } System.out.println("list使用時間:" + (System.currentTimeMillis() - begin)); // 用set隨機(jī) long begin1 = System.currentTimeMillis(); for (int i = 0; i < 100; i++) { tr.getGumBySet(); } System.out.println("set使用時間:" + (System.currentTimeMillis() - begin1)); } /* Set 獲取 */ void getGumBySet() { int random = new Random().nextInt(100); int prizeRate = 0;// 中獎率 Iteratorit = initSetGems().iterator(); while (it.hasNext()) { Gem gem = it.next(); prizeRate += gem.getPriority(); if (random < prizeRate) { System.out.println("獎品為:" + gem.getName() + " 概率:" + gem.getPriority() + " 隨機(jī)數(shù)random:" + random + " 概率基數(shù)prizeRate:" + prizeRate); break; } } } /** List 獲取 */ void getGumByList() { int random = new Random().nextInt(100); int prizeRate = 0;// 中獎率 Iterator it = initGems().iterator(); while (it.hasNext()) { Gem gem = it.next(); prizeRate += gem.getPriority(); if (random < prizeRate) { System.out.println("獎品為:" + gem.getName() + " 概率:" + gem.getPriority() + " 隨機(jī)數(shù)random:" + random + " 概率基數(shù)prizeRate:" + prizeRate); break; } } } /** 初始化list */ List initGems() { List gums = new ArrayList (); gums.add(new Gem("20", 20)); gums.add(new Gem("7", 7)); gums.add(new Gem("30", 30)); gums.add(new Gem("24", 40)); gums.add(new Gem("3", 3)); return gums; } /** 初始化set */ Set initSetGems() { Set gums = new HashSet (); gums.add(new Gem("20", 20)); gums.add(new Gem("7", 7)); gums.add(new Gem("30", 30)); gums.add(new Gem("24", 40)); gums.add(new Gem("3", 3)); return gums; } /**獎品類*/ class Gem { /** 獎品名稱 */ private String name; /** 獎品概率 */ private int priority; public Gem() { super(); } public Gem(String name, int priority) { super(); this.name = name; this.priority = priority; } @Override public String toString() { return "Gum [name=" + name + ", priority=" + priority + "]"; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getPriority() { return priority; } public void setPriority(int priority) { this.priority = priority; } } }
運行結(jié)果:
獎品為:20 概率:20 隨機(jī)數(shù)random:17 概率基數(shù)prizeRate:20
獎品為:30 概率:30 隨機(jī)數(shù)random:54 概率基數(shù)prizeRate:57
獎品為:3 概率:3 隨機(jī)數(shù)random:99 概率基數(shù)prizeRate:100
獎品為:24 概率:40 隨機(jī)數(shù)random:87 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:75 概率基數(shù)prizeRate:97
獎品為:7 概率:7 隨機(jī)數(shù)random:21 概率基數(shù)prizeRate:27
獎品為:20 概率:20 隨機(jī)數(shù)random:9 概率基數(shù)prizeRate:20
獎品為:24 概率:40 隨機(jī)數(shù)random:77 概率基數(shù)prizeRate:97
獎品為:20 概率:20 隨機(jī)數(shù)random:10 概率基數(shù)prizeRate:20
獎品為:24 概率:40 隨機(jī)數(shù)random:83 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:40 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:78 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:58 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:44 概率基數(shù)prizeRate:57
獎品為:7 概率:7 隨機(jī)數(shù)random:26 概率基數(shù)prizeRate:27
獎品為:30 概率:30 隨機(jī)數(shù)random:56 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:80 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:50 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:34 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:27 概率基數(shù)prizeRate:57
獎品為:20 概率:20 隨機(jī)數(shù)random:4 概率基數(shù)prizeRate:20
獎品為:24 概率:40 隨機(jī)數(shù)random:87 概率基數(shù)prizeRate:97
獎品為:20 概率:20 隨機(jī)數(shù)random:0 概率基數(shù)prizeRate:20
獎品為:24 概率:40 隨機(jī)數(shù)random:96 概率基數(shù)prizeRate:97
獎品為:7 概率:7 隨機(jī)數(shù)random:20 概率基數(shù)prizeRate:27
獎品為:30 概率:30 隨機(jī)數(shù)random:44 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:50 概率基數(shù)prizeRate:57
獎品為:7 概率:7 隨機(jī)數(shù)random:23 概率基數(shù)prizeRate:27
獎品為:24 概率:40 隨機(jī)數(shù)random:87 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:93 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:35 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:79 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:41 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:42 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:66 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:50 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:43 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:88 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:41 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:74 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:96 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:90 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:96 概率基數(shù)prizeRate:97
獎品為:20 概率:20 隨機(jī)數(shù)random:2 概率基數(shù)prizeRate:20
獎品為:24 概率:40 隨機(jī)數(shù)random:68 概率基數(shù)prizeRate:97
獎品為:7 概率:7 隨機(jī)數(shù)random:25 概率基數(shù)prizeRate:27
獎品為:20 概率:20 隨機(jī)數(shù)random:13 概率基數(shù)prizeRate:20
獎品為:30 概率:30 隨機(jī)數(shù)random:52 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:32 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:54 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:71 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:90 概率基數(shù)prizeRate:97
獎品為:3 概率:3 隨機(jī)數(shù)random:97 概率基數(shù)prizeRate:100
獎品為:30 概率:30 隨機(jī)數(shù)random:52 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:65 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:87 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:35 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:37 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:55 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:77 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:78 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:53 概率基數(shù)prizeRate:57
獎品為:20 概率:20 隨機(jī)數(shù)random:4 概率基數(shù)prizeRate:20
獎品為:24 概率:40 隨機(jī)數(shù)random:80 概率基數(shù)prizeRate:97
獎品為:20 概率:20 隨機(jī)數(shù)random:10 概率基數(shù)prizeRate:20
獎品為:24 概率:40 隨機(jī)數(shù)random:69 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:34 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:80 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:68 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:28 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:96 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:66 概率基數(shù)prizeRate:97
獎品為:20 概率:20 隨機(jī)數(shù)random:0 概率基數(shù)prizeRate:20
獎品為:24 概率:40 隨機(jī)數(shù)random:66 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:95 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:77 概率基數(shù)prizeRate:97
獎品為:20 概率:20 隨機(jī)數(shù)random:10 概率基數(shù)prizeRate:20
獎品為:7 概率:7 隨機(jī)數(shù)random:24 概率基數(shù)prizeRate:27
獎品為:30 概率:30 隨機(jī)數(shù)random:31 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:80 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:68 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:54 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:47 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:66 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:78 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:39 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:55 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:50 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:54 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:33 概率基數(shù)prizeRate:57
獎品為:30 概率:30 隨機(jī)數(shù)random:55 概率基數(shù)prizeRate:57
獎品為:24 概率:40 隨機(jī)數(shù)random:80 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:72 概率基數(shù)prizeRate:97
獎品為:3 概率:3 隨機(jī)數(shù)random:98 概率基數(shù)prizeRate:100
獎品為:24 概率:40 隨機(jī)數(shù)random:67 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:82 概率基數(shù)prizeRate:97
獎品為:7 概率:7 隨機(jī)數(shù)random:22 概率基數(shù)prizeRate:27
獎品為:24 概率:40 隨機(jī)數(shù)random:66 概率基數(shù)prizeRate:97
獎品為:20 概率:20 隨機(jī)數(shù)random:7 概率基數(shù)prizeRate:20
獎品為:30 概率:30 隨機(jī)數(shù)random:43 概率基數(shù)prizeRate:57
list使用時間:20
獎品為:7 概率:7 隨機(jī)數(shù)random:2 概率基數(shù)prizeRate:7
獎品為:24 概率:40 隨機(jī)數(shù)random:49 概率基數(shù)prizeRate:60
獎品為:24 概率:40 隨機(jī)數(shù)random:58 概率基數(shù)prizeRate:67
獎品為:20 概率:20 隨機(jī)數(shù)random:51 概率基數(shù)prizeRate:60
獎品為:24 概率:40 隨機(jī)數(shù)random:68 概率基數(shù)prizeRate:80
獎品為:24 概率:40 隨機(jī)數(shù)random:30 概率基數(shù)prizeRate:50
獎品為:24 概率:40 隨機(jī)數(shù)random:25 概率基數(shù)prizeRate:60
獎品為:20 概率:20 隨機(jī)數(shù)random:41 概率基數(shù)prizeRate:60
獎品為:24 概率:40 隨機(jī)數(shù)random:63 概率基數(shù)prizeRate:100
獎品為:30 概率:30 隨機(jī)數(shù)random:15 概率基數(shù)prizeRate:37
獎品為:30 概率:30 隨機(jī)數(shù)random:28 概率基數(shù)prizeRate:30
獎品為:24 概率:40 隨機(jī)數(shù)random:80 概率基數(shù)prizeRate:97
獎品為:20 概率:20 隨機(jī)數(shù)random:84 概率基數(shù)prizeRate:97
獎品為:3 概率:3 隨機(jī)數(shù)random:0 概率基數(shù)prizeRate:3
獎品為:24 概率:40 隨機(jī)數(shù)random:62 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:17 概率基數(shù)prizeRate:33
獎品為:20 概率:20 隨機(jī)數(shù)random:9 概率基數(shù)prizeRate:23
獎品為:24 概率:40 隨機(jī)數(shù)random:17 概率基數(shù)prizeRate:47
獎品為:20 概率:20 隨機(jī)數(shù)random:79 概率基數(shù)prizeRate:90
獎品為:30 概率:30 隨機(jī)數(shù)random:47 概率基數(shù)prizeRate:50
獎品為:24 概率:40 隨機(jī)數(shù)random:96 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:37 概率基數(shù)prizeRate:50
獎品為:30 概率:30 隨機(jī)數(shù)random:74 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:57 概率基數(shù)prizeRate:77
獎品為:24 概率:40 隨機(jī)數(shù)random:43 概率基數(shù)prizeRate:47
獎品為:30 概率:30 隨機(jī)數(shù)random:36 概率基數(shù)prizeRate:60
獎品為:24 概率:40 隨機(jī)數(shù)random:42 概率基數(shù)prizeRate:50
獎品為:20 概率:20 隨機(jī)數(shù)random:22 概率基數(shù)prizeRate:23
獎品為:24 概率:40 隨機(jī)數(shù)random:84 概率基數(shù)prizeRate:100
獎品為:24 概率:40 隨機(jī)數(shù)random:24 概率基數(shù)prizeRate:43
獎品為:24 概率:40 隨機(jī)數(shù)random:72 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:12 概率基數(shù)prizeRate:40
獎品為:24 概率:40 隨機(jī)數(shù)random:17 概率基數(shù)prizeRate:40
獎品為:30 概率:30 隨機(jī)數(shù)random:22 概率基數(shù)prizeRate:50
獎品為:20 概率:20 隨機(jī)數(shù)random:12 概率基數(shù)prizeRate:20
獎品為:30 概率:30 隨機(jī)數(shù)random:60 概率基數(shù)prizeRate:73
獎品為:24 概率:40 隨機(jī)數(shù)random:28 概率基數(shù)prizeRate:60
獎品為:24 概率:40 隨機(jī)數(shù)random:41 概率基數(shù)prizeRate:73
獎品為:24 概率:40 隨機(jī)數(shù)random:36 概率基數(shù)prizeRate:47
獎品為:24 概率:40 隨機(jī)數(shù)random:80 概率基數(shù)prizeRate:100
獎品為:30 概率:30 隨機(jī)數(shù)random:36 概率基數(shù)prizeRate:37
獎品為:7 概率:7 隨機(jī)數(shù)random:46 概率基數(shù)prizeRate:47
獎品為:24 概率:40 隨機(jī)數(shù)random:77 概率基數(shù)prizeRate:100
獎品為:24 概率:40 隨機(jī)數(shù)random:79 概率基數(shù)prizeRate:100
獎品為:7 概率:7 隨機(jī)數(shù)random:34 概率基數(shù)prizeRate:37
獎品為:24 概率:40 隨機(jī)數(shù)random:39 概率基數(shù)prizeRate:40
獎品為:30 概率:30 隨機(jī)數(shù)random:99 概率基數(shù)prizeRate:100
獎品為:20 概率:20 隨機(jī)數(shù)random:43 概率基數(shù)prizeRate:60
獎品為:7 概率:7 隨機(jī)數(shù)random:62 概率基數(shù)prizeRate:67
獎品為:24 概率:40 隨機(jī)數(shù)random:42 概率基數(shù)prizeRate:73
獎品為:7 概率:7 隨機(jī)數(shù)random:3 概率基數(shù)prizeRate:7
獎品為:24 概率:40 隨機(jī)數(shù)random:86 概率基數(shù)prizeRate:97
獎品為:24 概率:40 隨機(jī)數(shù)random:11 概率基數(shù)prizeRate:43
獎品為:24 概率:40 隨機(jī)數(shù)random:58 概率基數(shù)prizeRate:90
獎品為:24 概率:40 隨機(jī)數(shù)random:57 概率基數(shù)prizeRate:77
獎品為:30 概率:30 隨機(jī)數(shù)random:52 概率基數(shù)prizeRate:70
獎品為:7 概率:7 隨機(jī)數(shù)random:60 概率基數(shù)prizeRate:67
獎品為:24 概率:40 隨機(jī)數(shù)random:85 概率基數(shù)prizeRate:97
獎品為:20 概率:20 隨機(jī)數(shù)random:84 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:84 概率基數(shù)prizeRate:100
獎品為:24 概率:40 隨機(jī)數(shù)random:70 概率基數(shù)prizeRate:73
獎品為:24 概率:40 隨機(jī)數(shù)random:83 概率基數(shù)prizeRate:100
獎品為:24 概率:40 隨機(jī)數(shù)random:85 概率基數(shù)prizeRate:93
獎品為:30 概率:30 隨機(jī)數(shù)random:75 概率基數(shù)prizeRate:90
獎品為:20 概率:20 隨機(jī)數(shù)random:54 概率基數(shù)prizeRate:70
獎品為:30 概率:30 隨機(jī)數(shù)random:51 概率基數(shù)prizeRate:60
獎品為:24 概率:40 隨機(jī)數(shù)random:38 概率基數(shù)prizeRate:40
獎品為:30 概率:30 隨機(jī)數(shù)random:52 概率基數(shù)prizeRate:57
獎品為:20 概率:20 隨機(jī)數(shù)random:12 概率基數(shù)prizeRate:23
獎品為:20 概率:20 隨機(jī)數(shù)random:14 概率基數(shù)prizeRate:20
獎品為:24 概率:40 隨機(jī)數(shù)random:55 概率基數(shù)prizeRate:90
獎品為:20 概率:20 隨機(jī)數(shù)random:45 概率基數(shù)prizeRate:50
獎品為:7 概率:7 隨機(jī)數(shù)random:99 概率基數(shù)prizeRate:100
獎品為:24 概率:40 隨機(jī)數(shù)random:32 概率基數(shù)prizeRate:40
獎品為:30 概率:30 隨機(jī)數(shù)random:25 概率基數(shù)prizeRate:50
獎品為:30 概率:30 隨機(jī)數(shù)random:96 概率基數(shù)prizeRate:100
獎品為:20 概率:20 隨機(jī)數(shù)random:8 概率基數(shù)prizeRate:20
獎品為:20 概率:20 隨機(jī)數(shù)random:17 概率基數(shù)prizeRate:30
獎品為:20 概率:20 隨機(jī)數(shù)random:56 概率基數(shù)prizeRate:60
獎品為:24 概率:40 隨機(jī)數(shù)random:3 概率基數(shù)prizeRate:40
獎品為:7 概率:7 隨機(jī)數(shù)random:20 概率基數(shù)prizeRate:27
獎品為:20 概率:20 隨機(jī)數(shù)random:3 概率基數(shù)prizeRate:20
獎品為:24 概率:40 隨機(jī)數(shù)random:71 概率基數(shù)prizeRate:100
獎品為:24 概率:40 隨機(jī)數(shù)random:44 概率基數(shù)prizeRate:80
獎品為:24 概率:40 隨機(jī)數(shù)random:72 概率基數(shù)prizeRate:93
獎品為:24 概率:40 隨機(jī)數(shù)random:73 概率基數(shù)prizeRate:97
獎品為:20 概率:20 隨機(jī)數(shù)random:47 概率基數(shù)prizeRate:50
獎品為:20 概率:20 隨機(jī)數(shù)random:58 概率基數(shù)prizeRate:60
獎品為:24 概率:40 隨機(jī)數(shù)random:35 概率基數(shù)prizeRate:70
獎品為:20 概率:20 隨機(jī)數(shù)random:12 概率基數(shù)prizeRate:20
獎品為:30 概率:30 隨機(jī)數(shù)random:19 概率基數(shù)prizeRate:30
獎品為:3 概率:3 隨機(jī)數(shù)random:7 概率基數(shù)prizeRate:10
獎品為:24 概率:40 隨機(jī)數(shù)random:33 概率基數(shù)prizeRate:60
獎品為:20 概率:20 隨機(jī)數(shù)random:83 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:27 概率基數(shù)prizeRate:30
獎品為:3 概率:3 隨機(jī)數(shù)random:99 概率基數(shù)prizeRate:100
獎品為:24 概率:40 隨機(jī)數(shù)random:85 概率基數(shù)prizeRate:100
獎品為:20 概率:20 隨機(jī)數(shù)random:89 概率基數(shù)prizeRate:97
獎品為:30 概率:30 隨機(jī)數(shù)random:15 概率基數(shù)prizeRate:30
獎品為:24 概率:40 隨機(jī)數(shù)random:41 概率基數(shù)prizeRate:70
set使用時間:14
以上是“java如何實現(xiàn)的根據(jù)概率隨機(jī)中獎測試類”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!