Advertisement
Guest User

javabachan

a guest
Feb 16th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.69 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package ejercicio;
  7. import java.util.ArrayList;
  8. import java.util.List;
  9. import javax.swing.*;
  10.  
  11.  
  12. public class Main {
  13.    
  14.     private static ArrayList<Persona> personas = new ArrayList<Persona>();
  15.     private static Persona persona;
  16.    
  17.     public static void capturaPersona(){
  18.      
  19.         String nomPersona = JOptionPane.showInputDialog(null,"INGRESE EL NOMBRE DE LA PERSONA: ");
  20.         int edad = Integer.parseInt(JOptionPane.showInputDialog(null,"INGRESE LA EDAD DE LA PERSONA: "));
  21.         int cedula = Integer.parseInt(JOptionPane.showInputDialog(null,"INGRESE LA CEDULA DE LA PERSONA: "));
  22.         String apellido = JOptionPane.showInputDialog(null,"INGRESE EL APELLIDO DE LA PERSONA: ");      
  23.         int numCel = Integer.parseInt(JOptionPane.showInputDialog(null,"INGRESE EL NUMERO DE CELULAR: "));
  24.         int sueldo = Integer.parseInt(JOptionPane.showInputDialog(null,"INGRESE EL SUELDO DE LA PERSONA: "));
  25.         String cargo = JOptionPane.showInputDialog(null,"INGRESE EL CARGO DE LA PERSONA: ");
  26.         personas.add(new Persona(nomPersona,edad,cedula,apellido,numCel,sueldo,cargo));
  27.        
  28.     }
  29.    
  30.     public static void verPersonas(){
  31.        
  32.         for(int i = 0 ; i<personas.size() ; i++){
  33.             JOptionPane.showMessageDialog(null,"nombre: " + personas.get(i).getNombre() +
  34.                     "\n Cedula: " + personas.get(i).getCc());
  35.                    
  36.         }
  37.     }
  38.    
  39.     public static void cambiarCedula(){
  40.          for(int i = 0 ; i<personas.size() ; i++){        
  41.           personas.get(i).setCc(Integer.parseInt(JOptionPane.showInputDialog(null,"Ingrese la nueva cedula")));
  42.           JOptionPane.showMessageDialog(null, "CEDULA CAMBIADA CON EXITO");
  43.         }
  44.        
  45.        
  46.     }
  47.            
  48.            
  49.     public static void main (String[]args){
  50.         int opcion;
  51.         do{
  52.          opcion = Integer.parseInt(JOptionPane.showInputDialog(null,"Digite"
  53.                 + "\n 1. Insertar Persona" +
  54.                   "\n 2. Ver Personas" +
  55.                   "\n 3. Cambiar Cedula" +
  56.                   "\n 3. Salir"));
  57.                
  58.             switch (opcion) {
  59.                 case 1: capturaPersona(); break;
  60.                 case 2: verPersonas();break;
  61.                 case 3: cambiarCedula();break;
  62.                 case 4: JOptionPane.showMessageDialog(null,"Salir");
  63.                 default:opcion = 0; JOptionPane.showMessageDialog(null,"Digite una opcion valida");
  64.             }
  65.         }while(opcion<4);        
  66.     }
  67.    
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement