Lista trabajador
Upcoming SlideShare
Loading in...5
×
 

Lista trabajador

on

  • 144 views

listas

listas

Statistics

Views

Total Views
144
Views on SlideShare
144
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Lista trabajador Lista trabajador Document Transcript

    • package Lista; publicclassListaTrabajador { private Trabajador p=null; privateclass Trabajador{ private String dni; private String nombre; private String apellido; privateintdias; privatedoublejornaldia; Trabajador siguiente; private double calcularsueldo(){ returnjornaldia*dias; } } public void agregar(double j, String d, String n, String a, int di){ ListaTrabajador.Trabajador q=new ListaTrabajador.Trabajador(); q.dni=d; q.nombre=n; q.apellido=a; q.dias=di; q.jornaldia=j;
    • q.siguiente=p; p=q; } publicStringmostrarnombre(){ ListaTrabajador.Trabajador q=p; String valor=""; while(q!=null) { valor=valor+q.nombre+" "+q.apellido+"n"; q=q.siguiente; } return valor; } publicStringmostrardias(){ ListaTrabajador.Trabajador q=p; String valor=""; while(q!=null) { valor=valor+q.dias+"n"; q=q.siguiente; } return valor; } publicStringmostrarjornal(){
    • ListaTrabajador.Trabajador q=p; String valor=""; while(q!=null) { valor=valor+q.jornaldia+"n"; q=q.siguiente; } return valor; } publicStringmostrarsueldo(){ ListaTrabajador.Trabajador q=p; String valor=""; while(q!=null) { valor=valor+q.calcularsueldo()+"n"; q=q.siguiente; } return valor; } } FRM package Prueba; importLista.ListaTrabajador;
    • importLista.Listasimple; importjavax.swing.JOptionPane; publicclassfrmlistatrabajadorextendsjavax.swing.JFrame { publicListaTrabajadorlst=new ListaTrabajador(); publicfrmlistatrabajador() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); btnnuevo = new javax.swing.JButton(); btnagregar = new javax.swing.JButton(); btnmostrar = new javax.swing.JButton(); btnsalir = new javax.swing.JButton(); txtdni = new javax.swing.JTextField(); txtnombre = new javax.swing.JTextField(); txtapellido = new javax.swing.JTextField(); txtdias = new javax.swing.JTextField();
    • txtjornal = new javax.swing.JTextField(); jScrollPane1 = new javax.swing.JScrollPane(); txtarea = new javax.swing.JTextArea(); jScrollPane2 = new javax.swing.JScrollPane(); txtarea1 = new javax.swing.JTextArea(); jScrollPane3 = new javax.swing.JScrollPane(); txtarea2 = new javax.swing.JTextArea(); jScrollPane4 = new javax.swing.JScrollPane(); txtarea3 = new javax.swing.JTextArea(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jLabel1.setText("DNI"); getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(24, 14, -1, -1)); jLabel2.setText("NOMBRES"); getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(24, 57, -1, -1)); jLabel3.setText("APELLIDOS"); getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(24, 97, -1, -1));
    • jLabel4.setText("DIAS TRABAJADOS"); getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(24, 137, -1, 1)); jLabel5.setText("JORNAL DEL DIA"); getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(24, 177, -1, 1)); btnnuevo.setText("NUEVO"); btnnuevo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { btnnuevoActionPerformed(evt); } }); getContentPane().add(btnnuevo, new org.netbeans.lib.awtextra.AbsoluteConstraints(42, 229, -1, 1)); btnagregar.setText("AGREGAR"); btnagregar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { btnagregarActionPerformed(evt); } }); getContentPane().add(btnagregar, new org.netbeans.lib.awtextra.AbsoluteConstraints(178, 229, 1, -1)); btnmostrar.setText("MOSTRAR");
    • btnmostrar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { btnmostrarActionPerformed(evt); } }); getContentPane().add(btnmostrar, new org.netbeans.lib.awtextra.AbsoluteConstraints(315, 229, 1, -1)); btnsalir.setText("SALIR"); btnsalir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { btnsalirActionPerformed(evt); } }); getContentPane().add(btnsalir, new org.netbeans.lib.awtextra.AbsoluteConstraints(466, 229, -1, 1)); getContentPane().add(txtdni, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 10, 130, 30)); txtnombre.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { txtnombreActionPerformed(evt); } }); getContentPane().add(txtnombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 50, 350, 30));
    • getContentPane().add(txtapellido, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 90, 350, 30)); getContentPane().add(txtdias, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 130, 130, 30)); txtjornal.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEventevt) { txtjornalActionPerformed(evt); } }); getContentPane().add(txtjornal, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 170, 130, 30)); txtarea.setColumns(20); txtarea.setRows(5); jScrollPane1.setViewportView(txtarea); getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(24, 295, 181, -1)); txtarea1.setColumns(20); txtarea1.setRows(5); jScrollPane2.setViewportView(txtarea1); getContentPane().add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 295, 106, -1));
    • txtarea2.setColumns(20); txtarea2.setRows(5); jScrollPane3.setViewportView(txtarea2); getContentPane().add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(344, 295, 96, -1)); txtarea3.setColumns(20); txtarea3.setRows(5); jScrollPane4.setViewportView(txtarea3); getContentPane().add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(466, 295, 103, -1)); jLabel6.setText("DIAS TRAB"); getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 270, -1, 1)); jLabel7.setText("JORNAL DIA"); getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(356, 270, -1, 1)); jLabel8.setText("SUELDO"); getContentPane().add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(472, 270, -1, 1)); jLabel9.setText("NOMBRES Y APELLIDOS");
    • getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(33, 270, -1, 1)); pack(); }// </editor-fold> private void txtjornalActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: } private void txtnombreActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: } private void btnagregarActionPerformed(java.awt.event.ActionEventevt) { String d, a, n; int di; double jo; d=txtdni.getText(); n=txtnombre.getText(); a=txtapellido.getText(); di=Integer.parseInt(txtdias.getText()); jo=Double.parseDouble(txtjornal.getText()); lst.agregar(jo, d, n, a, di); }
    • private void btnmostrarActionPerformed(java.awt.event.ActionEventevt) { txtarea.append(lst.mostrarnombre()); txtarea1.append(lst.mostrardias()); txtarea2.append(lst.mostrarjornal()); txtarea3.append(lst.mostrarsueldo()); } private void btnsalirActionPerformed(java.awt.event.ActionEventevt) { int x=JOptionPane.showConfirmDialog(rootPane, "DeseaSalir", "Salir", JOptionPane.INFORMATION_MESSAGE); if(x==0) System.exit(0); } private void btnnuevoActionPerformed(java.awt.event.ActionEventevt) { txtdni.setText("") ; txtnombre.setText("") ; txtapellido.setText("") ; txtdias.setText("") ; txtjornal.setText("") ; txtarea.setText("") ; txtarea1.setText("") ; txtarea2.setText("") ; txtarea3.setText("") ; }
    • /** * @paramargs 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.html */ 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(frmlistatrabajador.class.getName()).log(java.util.logging.Level.SE VERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(frmlistatrabajador.class.getName()).log(java.util.logging.Level.SE VERE, null, ex); } catch (IllegalAccessException ex) {
    • java.util.logging.Logger.getLogger(frmlistatrabajador.class.getName()).log(java.util.logging.Level.SE VERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(frmlistatrabajador.class.getName()).log(java.util.logging.Level.SE VERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new frmlistatrabajador().setVisible(true); } }); }