package com.twocolorball.www;
import java.util.Arrays;
import java.util.Random;
public class TwoColorBall {
public static void main(String[] args) {
int[] red = redBall() ;
blue();
}
/**
* 红球的随机数
*/
private static int[] redBall() {
int arrRed [] = new int[6] ;
boolean bRed[] = new boolean[33] ;
bRed[0] = true ;
int index ;
Random random = new Random();
for (int i = 0 ; i<arrRed.length ;i++) {
do {
index = random.nextInt(32) ;
} while (bRed[index] == true ) ;
arrRed[i] = index ;
bRed[index] = true ;
}
Arrays.sort(arrRed) ;
System.out.println("红球随机产生的数为:"+String.valueOf(Arrays.toString(arrRed)));
return arrRed ;
}
/**
* 篮球的随机数
*/
private static void blue(){
int index ;
do{
index =(int) (Math.random()*16) ;
}while(index == 0) ;
System.out.println("篮球随机产生的数为:"+index);
}
}