import java.util.Random;
import java.awt.*;
import java.awt.event.*;
public class shuangSeQiu implements ActionListener{
int i,k;
static int rm,rr;
int [] a = new int [33];
Frame f = new Frame("雙色球隨機數");
TextField tf = new TextField();
Random rd = new Random();
public shuangSeQiu()
{
for(i=0;i<33;i++)
{
a[i] = i;
}
f.setLayout(new BorderLayout());
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public void init()
{
tf.addActionListener(this);
Button b = new Button("開始");
b.addActionListener(this);
f.add(tf,"North");
f.add(b);
f.setSize(300,300);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("開始"))
//tf.setText(""+(rd.nextInt(33)+1)+" "+(rd.nextInt(33)+1)+" "+(rd.nextInt(33)+1)+" "+(rd.nextInt(33)+1)+" "+(rd.nextInt(33)+1)+" "+(rd.nextInt(33)+1)+" 藍色球號碼:"+(rd.nextInt(15)+1));
{
/*rr = new Random().nextInt(33);
rm = new Random().nextInt(33);*/
for(i=0;i<33;i++)
{
rr = new Random().nextInt(33);
rm = new Random().nextInt(33);
System.out.print(rr+" ");
k=a[rm];
a[rm]=a[rr];
a[rr]=k;
}
tf.setText("紅色球號碼:"+(a[0]+1)+" "+(a[1]+1)+" "+(a[2]+1)+" "+(a[3]+1)+" "+(a[4]+1)+" "+(a[5]+1)+" 藍色球號碼:"+(rd.nextInt(15)+1));
}
}
public static void main(String[] args)//throws Exception
{
new shuangSeQiu().init();
}
}