public class YaoHao {
public static void main(String[] args) {
// TODO Auto-generated method stub
Set<Integer> set = new HashSet<Integer>();
Random rd = new Random();
Set<Integer> set2 = new HashSet<Integer>();
Random rd2 = new Random();
System.out.println("红色球");
yaohaoR(set, rd);
System.out.println("蓝色球");
yaohaoB(set2,rd2);
}
private static void yaohaoB(Set<Integer> set, Random rd) {
// TODO Auto-generated method stub
for (int temp = 0; temp < 1; temp++) {
set.add(new Integer(rd.nextInt(16)));
}
Iterator<Integer> it = set.iterator();
System.out.println(it.next()+1);
}
private static void yaohaoR(Set<Integer> set2, Random rd2) {
// TODO Auto-generated method stub
for (int temp = 0; temp < 6; temp++) {
set2.add(new Integer(rd2.nextInt(33)));
}
if (set2.size() < 6) {
set2.clear();
yaohaoR(set2, rd2);
} else {
Iterator<Integer> it = set2.iterator();
while (it.hasNext()) {
System.out.println(it.next());
}
}
}
}
大家有兴趣的话可以给加一个根据结果进行判断谁中奖 |
|