El software de lotería debe estar escrito en Java
importar java.awt.event.WindowAdapter;
importar java.awt.event.WindowEvent;
importar java.util.Random;
importar javax.swing.JFrame;
importar javax.swing.JTextField;
la clase pública RandomTest extiende JFrame implementa Runnable {
JTextField tf = new JTextField();
public RandomTest() {
this.add(tf
this.setSize(300, 200);
this.setVisible(true);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
// Sistema.exit(0);
disponer();
}
}); > public void run() {
String[] list = { "aaa", "123", "Zhang San", "Li Si" };
int time = 100 ; //Resultados en 3 segundos
Random rd = new Random(); // Clase de generación de números aleatorios
int i = 0;
while ( tiempo gt; 0) {
prueba {
i = rd.nextInt(list.length)
tf.setText(list[i]); /p>
Thread.sleep(10);
tiempo --;
} catch (InterruptedException e) {
// TODO Auto - bloque de captura generado
e.printStackTrace();
}
}
tf.setText("Ganador:" lista [i ]);
}
public static void main(String[] args) {
nuevo hilo(new RandomTest()).start() ;
}
}