miércoles, 10 de noviembre de 2010

Altas, Bajas , Consultas ,Modificaciones java(netbeans)

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author Alejandra
 */
public class EmpledosEcep{
     private  String nombre;
     private String dpto;
     private double salario;
     private int dia;
     private int mes;
     private int a;
     float mensual;
     int antiguedad;
    public EmpledosEcep(){
    }
     public EmpledosEcep(String nombre , String dpto ,double salario, int dia , int mes , int a){
        this.nombre=nombre;
        this.dpto=dpto;
        this.salario=salario;
        this.dia=dia;
        this.mes=mes;
        this.a=a;
    }
    public int getAntiguedad() {
        return antiguedad;
    }
    public void setAntiguedad(int antiguedad) {
        this.antiguedad = antiguedad;
    }
    public void setA(int a) {
        this.a = a;
    }
    public void setDia(int dia) {
        this.dia = dia;
    }
    public void setDpto(String dpto) {
        this.dpto = dpto;
    }
    public void setMes(int mes) {
        this.mes = mes;
    }
    public void setNombre(String nombre) {
        this.nombre = nombre;
    }
    public void setSalario(double salario) {
        this.salario = salario;
    }
    public int getA() {
        return a;
    }
    public int getDia() {
        return dia;
    }
    public String getDpto() {
        return dpto;
    }
    public int getMes() {
        return mes;
    }
    public String getNombre() {
        return nombre;
    }
    public double getSalario() {
        return salario;
    }
    public float getMensual() {
        return mensual;
    }
    public void setMensual(float mensual) {
        this.mensual = mensual;
    }
}
-----------------------------------------------------------------------------------------------------

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author Alejandra
 */
import java.io.*;
public class mtdEcep {
    int p=0, pos=-1;
     public void registrar(EmpledosEcep[] em , int x)throws IOException{
        BufferedReader i= new BufferedReader(new InputStreamReader(System.in));
        System.out.println("\n\n\nNombre del empleado: ");
        String no=i.readLine();
        String[] v=no.split(" ");
        System.out.println("\nDepartamento donde labora:  ");
        String de=i.readLine();
        System.out.println("\nsalario diario: ");
        float sa=Float.parseFloat(i.readLine());
        System.out.println("\nfecha de ingreso");
        System.out.println("dia 00/00/0000:");
        int d=Integer.parseInt(i.readLine());
        System.out.println("mes 00/00/0000:");
        int m=Integer.parseInt(i.readLine());
        System.out.println("año 00/00/0000: ");
        int an=Integer.parseInt(i.readLine());
        em[x]= new EmpledosEcep(no,de,sa,d,m,an);
        float men=(sa*30);
        em[x].setMensual(men);
        int ant=(2010-an);
        em[x].setAntiguedad(ant);
        p=x;
     }
     public void consultaG(EmpledosEcep[] em1, int x)throws IOException{
         BufferedReader i=new BufferedReader(new InputStreamReader(System.in));
         System.out.println("--------------------------------------------------------------------------------");
         System.out.println("NOMBRE\t\tDEPARTAMENTO\tSALARIO MENSUAL\tDIARIO\tFECHA DE INGRESO\n");
         for(int z=0 ; z<x ; z++){
             System.out.println(em1[z].getNombre()+"\t  "+em1[z].getDpto()+"\t  "+em1[z].getMensual() +"\t\t"+em1[z].getSalario()+"   "+em1[z].getDia()+"/"+em1[z].getMes()+"/"+em1[z].getA());
         }
         System.out.println("---------------------------------------------------------------------------------");
     }
     public int busqueda(EmpledosEcep[] em2, int x)throws IOException{
          BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
          int ll=0,j=0;
          String desc="NULL";
          System.out.println("\nNombre: ");
          String busca= in.readLine();
           String[] v=busca.split(" ");
          for(int i=0;i<x;i++){
            desc=em2[i].getNombre();
            if(desc.equalsIgnoreCase(busca)){
            ll=i;
            }
          }
          System.out.println("Nombre: "+em2[ll].getNombre()+" Departamento: "+em2[ll].getDpto()+" Salario: "+em2[ll].getSalario());
          return x;
     }
          public int busqued(EmpledosEcep[] e5, int x)throws IOException{
          BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
          int ll=0,j=0;
          String desc="NULL";
          System.out.println("\nDepartamento: ");
          String busca= in.readLine();
          for(int i=0;i<x;i++){
              desc=e5[i].getDpto();
              if(desc.equalsIgnoreCase(busca)){
              ll=i;
              }
          }
          System.out.println("Nombre: "+e5[ll].getNombre()+" Departamento: "+e5[ll].getDpto()+" Salario: "+e5[ll].getSalario());
          return x;
     }
     public int busqueda(EmpledosEcep[] e1)throws IOException{
          BufferedReader n= new BufferedReader(new InputStreamReader(System.in));
          int aux=0,k=0, j=0;
          System.out.println("\nAntiguedad: ");
          int busca=Integer.parseInt(n.readLine());
          for(int i=0;i<p;i++){
              aux=e1[i].getAntiguedad();
              if(busca==aux){
              k=i;
              }
         }
         System.out.println("Nombre: "+e1[k].getNombre()+" Departamento: "+e1[k].getDpto()+" Salario: "+e1[k].getSalario());
         return k;
     }
     public int bajas(EmpledosEcep[] empZ, int x) throws IOException{
        BufferedReader k = new BufferedReader(new InputStreamReader(System.in));
        int h = 0;
        System.out.println("Introduzca el nombre:");
        String baja = k.readLine();
        for(int y=0;y<x;y++){
            String nomb = empZ[y].getNombre();
            if(nomb.equalsIgnoreCase(baja)){
                h = y;
                System.out.println(empZ[h].getNombre()+"\t"+empZ[h].getDpto());
                System.out.println("Desea darlo de baja? (si/no):");
                String r = k.readLine();
                if(r.equalsIgnoreCase("si"))
                    for(int a=h;a<x;a++)
                        empZ[a]=empZ[a+1];
                x--;
                p--;
                y=x;
                if(r.equalsIgnoreCase("no"))
                    System.out.println("No se eliminara");
            }
        }
        return x;
    }
     public void modificaciones(EmpledosEcep[] e6, int x)throws IOException{
          BufferedReader in= new BufferedReader(new InputStreamReader(System.in));  
          int ll=0;
          float sn=0;
          String desc="NULL";
                System.out.println("\nNombre: ");
                String busca= in.readLine();
                for(int i=0;i<x;i++){
                   desc=e6[i].getNombre();
                    if(desc.equalsIgnoreCase(busca)){
                           ll=i;
                    }
                }
                System.out.println("Ingresa nuevo salario: ");
                sn=Float.parseFloat(in.readLine());
                e6[ll].setSalario(sn);
                float me=(sn*30);
                e6[ll].setMensual(me);
 }
     }
-------------------------------------------------------------------------------------------------------------

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author Alejandra
 */
import java.io.*;
public class principalEcep {
    public static void main(String[] args)throws IOException{
        BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
        EmpledosEcep[] emp=new EmpledosEcep[20];
        mtdEcep obj=new mtdEcep();
        int x=0,op;
        String r="n";
      
        do{
        System.out.println("\t\tMENU:\n\n");
        System.out.println("\t1.Registrar\n");
        System.out.println("\t2.Consulta general\n");
        System.out.println("\t3.Busqueda\n");
        System.out.println("\t4.Bajas\n");
        System.out.println("\t5.Modificaciones\n");
        System.out.println("\t6.Salir\n");
        System.out.println("Elige tu opcion: ");
        op=Integer.parseInt(in.readLine());
        switch(op){
            case 1:
               do{
                obj.registrar(emp, x);
                x++;
                System.out.println("\n\n\n\tdesea continuar s/n");
                r=in.readLine();
                }while(!r.equalsIgnoreCase("n"));
                break;
            case 2:
                obj.consultaG(emp, x);
                break;
            case 3:
               int opc;
                do{
                    System.out.println("\n\n\tSUBMENU BUSQUEDAS");
                    System.out.println("1.Busqueda por nombre");
                    System.out.println("2.Busqueda por antiguedad");
                    System.out.println("3.Busqueda por deparrtamento");
                    System.out.println("4.Salir al menu");
                    System.out.println("elegir opcion");
                    opc=Integer.parseInt(in.readLine());
                    switch(opc){
                        case 1:
                            int o=0;
                          
                            o=obj.busqueda(emp, x);

                            break;
                        case 2:
                            int p=0;
                          
                            p=obj.busqueda(emp);
                            break;
                        case 3:
                            int y=0;
                          
                            y=obj.busqued(emp, x);
                            break;
                        case 4:
                            break;
                    }
                }while(opc!=4);
                break;
            case 4:
                x= obj.bajas(emp, x);
                break;
            case 5:
                obj.modificaciones(emp, x);
                break;
            case 6:
                break;
        }
        }while(op!=6);
     }
}

1 comentario: