博客园站长
这是人类成长进步中记录的每一时刻

 

import java.util.Random;
 
import org.junit.Test;
 
public class Demo1 {
	public void getChance(int percentage){
		Random random = new Random();
		int i = random.nextInt(99);
		if(i>=0&&i<percentage)
			System.out.println("true");
		else
			System.out.println("false");
	}
	@Test
	public void test(){
		for(int i=0;i<100;i++){
			this.getChance(76);  //76%概率
		}
	}

  

posted on 2018-08-08 16:01  dm3344  阅读(247)  评论(0编辑  收藏  举报