2011年3月24日 星期四

樂透+強

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class ButtonText  extends JFrame                     
  implements ActionListener { 
  public static void main(String[] args) {
    ButtonText test = new ButtonText();
}
ButtonText ()
{
    Frame frame=new Frame("Button Frame");
    Button button1 = new Button("Submit");
    Button button2 = new Button("Submit");
    button1.addActionListener(this);
    frame.add(button1);
    frame.add(button2);
    frame.setLayout(new FlowLayout());
    frame.setSize(200,100);
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e){
     System.exit(0);
    }
     });
     }

 public void actionPerformed(ActionEvent e)
{
int loto[ ]=new int[7];
for(int i=0;i<loto.length;i++)
{
int a;
a=(int) (Math.random()*49+1) ;
loto[i]=a;
if(i==6) 
 System.out.println("特別號:"+loto[i]);
else
 System.out.println("第"+(i+1)+"個開獎號碼:"+loto[i]);
}
}
}

沒有留言:

張貼留言