Professional Documents
Culture Documents
Nombre: Diego Noguera Vsconez Tema: Ruleta de la fortuna Fecha de envode trabajo: Viernes 1 de junio del 2012 Paralelo/Carrera: Segundo/Ingeniera en informtica Docente: Ing. Boris Herrera
ENUNCIADO:
REALIZAR UNA RULETA DE PREMIOS DE N ELEMENTOS Y QUE EL PUNTERO MARQUE EL RESULTADO OBTENIDO
jLayeredPane1 = new javax.swing.JLayeredPane(); Ruleta2 = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); Ruleta1 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel();
Ruleta2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/ruleta2. png"))); // NOI18N Ruleta2.setBounds(0, 40, 290, 291); jLayeredPane1.add(Ruleta2, javax.swing.JLayeredPane.DEFAULT_LAYER);
jButton2.setText("Iniciar"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton2.setBounds(300, 60, 90, 23); jLayeredPane1.add(jButton2, javax.swing.JLayeredPane.DEFAULT_LAYER);
Ruleta1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/ruleta.gi f"))); // NOI18N Ruleta1.setBounds(0, 40, 290, 291); jLayeredPane1.add(Ruleta1, javax.swing.JLayeredPane.DEFAULT_LAYER);
jButton1.setText("Salir");
jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton1.setBounds(300, 300, 90, 23); jLayeredPane1.add(jButton1, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N jLabel1.setText("Rueda de la Fortuna"); jLabel1.setBounds(10, 0, 320, 30); jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING) .addGroup(layout.createSequentialGroup() .addContainerGap()
.addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING) .addGroup(layout.createSequentialGroup() .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 337, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { dispose();// TODO add your handling code here: }
BufferedReader buff= new BufferedReader(new InputStreamReader(System.in)); int Elementos=Integer.parseInt(JOptionPane.showInputDialog (null,"INGRESE EL NUMERO DE ELEMENTOS DE LA RULETA")); int Multiplo=Integer.parseInt(JOptionPane.showInputDialog (null,"INGRESE EL NUMERO MULTIPLO DE LOS VALORES DE LA RUEDA")); Nodo listac=new Nodo();
listac.dato=Multiplo; listac.sig=listac; //insercin horaria Nodo anterior=listac; Nodo temp; System.out.println(""); System.out.println(""); System.out.println("///////////////VALORES DE LA RUEDA DE LA FORTUNA////////////"); for(int i=2;i<=Elementos;i++) { temp=new Nodo(); temp.dato=i*Multiplo; temp.sig=listac; anterior.sig=temp; anterior=temp; }
temp = listac; for (int i= 1; i <=Elementos; i++) { System.out.println(temp.dato); temp =temp.sig; } JOptionPane.showMessageDialog (null,"RUEDA DE LA FORTUNA");
int opcion; VentanaRuleta abrir = new VentanaRuleta(); do{ opcion= JOptionPane.showConfirmDialog(null, "DESEA GIRAR LA RULETA");
if (opcion==1) // no
if (opcion==0){//si Ruleta1.setVisible(true); Ruleta2.setVisible(false); int posicion_giro=0; JOptionPane.showMessageDialog (null," LA RUEDA ESTA GIRANDO..."+"\nDETENER!!!!!");
do{ posicion_giro=(int)(Math.random()*100); System.out.println("NUMERO DE POSICIONES QUE RECORRERA EL PUNTERO DE LA RULETA "+posicion_giro); }while(posicion_giro<=Elementos); //System.out.println("numero randomico generado= "+posicion_giro);
} temp=listac; JOptionPane.showMessageDialog (null,"EL VALOR QUE GANO ES "+temp.dato+" DLARES"+ "\n y la posicion del puntero es " +cont+" en la lista circular"); } }while(opcion==0);
/** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.h tml */ try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(VentanaRuleta.class.getName()). log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(VentanaRuleta.class.getName()). log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(VentanaRuleta.class.getName()). log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(VentanaRuleta.class.getName()). log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() { new VentanaRuleta().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JLabel Ruleta1; private javax.swing.JLabel Ruleta2; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLayeredPane jLayeredPane1; // End of variables declaration }