彩票2
package com.lovo.bean;
import java.util.ArrayList;
import java.util.List;
public class Qiu {
public void run(){
this.hongQiu();
this.lanQiu();
}
//蓝球机选号码方法
private void hongQiu(){
List<Integer> num = new ArrayList<Integer>();
int i = 0;
while(true){
i = (int)(Math.random()*33+1);//随机产生1~33的整数
if (!num.contains(i)) {//判断集合里是否包含元素i
num.add(i);
if (num.size()==6) {
break;
}
}
}
System.out.print("您机选的号码是:"+num);
}
//蓝球机选号码方法
private void lanQiu(){
int b = 0 ;
b = (int)(Math.random()*16+1);//随机产生1~16的整数
System.out.println(" "+b);
}
}