elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Guía actualizada para evitar que un ransomware ataque tu empresa


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Java
| | | |-+  ayuda plis, quebrando me el coco buscando por que esta mal
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 Ir Abajo Respuesta Imprimir
Autor Tema: ayuda plis, quebrando me el coco buscando por que esta mal  (Leído 5,338 veces)
sevid

Desconectado Desconectado

Mensajes: 7


Ver Perfil
ayuda plis, quebrando me el coco buscando por que esta mal
« en: 14 Noviembre 2009, 15:32 pm »

Código:
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Vector;


public class Validador {
    Archivo archivo;
    
    Vector regiones;
    Vector agencias;
    Vector presupuestos;
    Vector presdags;
    
    public Validador() throws FileNotFoundException, IOException{
        try{
            this.archivo=new Archivo();
            this.regiones=new Vector();
            this.agencias=new Vector();

            this.getRegiones();
            this.getAgencias();
           /*AQUI ERROR*/ :-X
Código:
  
           /*AQUI EL ERROR*/
            this.presupuestos=this.archivo.getPresupuestos("Presupuestos");

            //MODIFICAR
            this.presdags=this.archivo.getPresdag("PRESDAG_INNOVACION2009_2008_V1");

        }catch(Exception e){
            System.out.println("********************error**********************");
            e.printStackTrace();
        }
     }
            
      
    public static void main(String[] args) throws FileNotFoundException, IOException {
        
        Validador principal =new Validador();



        System.out.println("********************REGIONES**********************");
        principal.MostrarRegiones();
        System.out.println("********************AGENCIAS**********************");
        principal.MostrarAgencias();
        System.out.println("********************Presupuesto**********************");
        principal.MostrarPresupuestos();
        System.out.println("********************PRESDAG**********************");
        principal.MostrarPresdag();
        
    }
    
    public void MostrarRegiones(){
        for(int i=0;i<this.regiones.size();i++){
            System.out.println(((Region)(this.regiones.elementAt(i))).obtenerRegion()+" "+((Region)this.regiones.elementAt(i)).obtenerNombre());
        }
    }
    public void MostrarAgencias(){
        for(int i=0;i<this.agencias.size();i++){
            System.out.println(((Agencia)this.agencias.elementAt(i)).obtenerNombre());
        }
    }
    
    public void MostrarPresupuestos(){
        for(int i=0;i<this.presupuestos.size();i++){
            System.out.println(((Presupuesto)this.presupuestos.elementAt(i)).obtenerAño()+"   "+((Presupuesto)this.presupuestos.elementAt(i)).obtenerMonto()+" "+((Presupuesto)this.presupuestos.elementAt(i)).obtenerAgencia());
        }
    }
    public void MostrarPresdag(){
        for(int i=0;i<this.presdags.size();i++){
            System.out.println(((Presdag)this.presdags.elementAt(i)).obtenerNumeroProyecto()+" ; "+((Presdag)this.presdags.elementAt(i)).obtenerDescripcionProyecto()+" "+((Presdag)this.presdags.elementAt(i)).obtenerNombreAgencia()+" ; "+((Presdag)this.presdags.elementAt(i)).obtenerAnoPresupuesto()+" ; "+((Presdag)this.presdags.elementAt(i)).obtenerNombreRegion()+" ; "+((Presdag)this.presdags.elementAt(i)).obtenerGastos()+" ; "+((Presdag)this.presdags.elementAt(i)).obtenerFecha());
        }
    }


    private void getAgencias(){
        this.agencias.add(new Agencia("Innovacion Nacional"));
        this.agencias.add(new Agencia("Educacion Nacional"));
        this.agencias.add(new Agencia("Mineria Norte"));
        this.agencias.add(new Agencia("Fomento y Desarrollo"));
        this.agencias.add(new Agencia("Planificacion Nacional"));
    }
    /******************************************************/
    
    private void getRegiones() {
        this.regiones.add(new Region("I", "TARAPACA"));
        this.regiones.add(new Region("II", "ANTOFAGASTA"));
        this.regiones.add(new Region("III", "ATACAMA"));
        this.regiones.add(new Region("IV", "COQUIMBO"));
        this.regiones.add(new Region("V", "VALPARAISO"));
        this.regiones.add(new Region("VI", "LIBERTADOR GENERAL BERNARDO O'HIGGINS"));
        this.regiones.add(new Region("VII", "MAULE"));
        this.regiones.add(new Region("VIII", "BIO - BIO"));
        this.regiones.add(new Region("IX", "LA ARAUCANIA"));
        this.regiones.add(new Region("X", "LOS LAGOS"));
        this.regiones.add(new Region("XI", "AYSEN DEL GENERAL CARLOS IBAÑEZ DEL CAMPO"));
        this.regiones.add(new Region("XII", "MAGALLANES Y LA ANTARTICA CHILENA"));
        this.regiones.add(new Region("XIII", "METROPOLITANA"));
        this.regiones.add(new Region("XIV", "LOS RIOS"));
        this.regiones.add(new Region("XV", "ARICA Y PARINACOTA"));
    }


}



« Última modificación: 15 Noviembre 2009, 00:33 am por sevid » En línea

Leyer


Desconectado Desconectado

Mensajes: 786


leyer@elhacker.net


Ver Perfil WWW
Re: ayuda plis, quebrando me el coco buscando por que esta mal
« Respuesta #1 en: 14 Noviembre 2009, 15:38 pm »

me da errores faltan clases. cuando dices esto this.presupuestos=this.archivo.getPresupuestos("Presupuestos"); estas seguro que esta retornando los presupueto.

Saludos.


« Última modificación: 14 Noviembre 2009, 15:40 pm por L-EYER » En línea

sevid

Desconectado Desconectado

Mensajes: 7


Ver Perfil
Re: ayuda plis, quebrando me el coco buscando por que esta mal
« Respuesta #2 en: 14 Noviembre 2009, 15:41 pm »

es que el programa es mas extenso, pero serian muchas clases y ocupan archivos .csv

pero basicamente me tira error de compilacion alli

aqui esta la clase para sacar de archivo y la de presupuesto
Código:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
//import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
//import java.text.SimpleDateFormat;

public class Archivo {
    Vector vector;
    

    FileReader archivo;
    BufferedReader bufferArchivo;

    
    BufferedWriter bufferArchivoEscribir;

    
    
    public Archivo() throws FileNotFoundException, IOException{
        this.vector=new Vector();
    }

    
    public Vector getPresupuestos(String nombre) throws FileNotFoundException, IOException{
        String sCadena, celdas[];
        int contador=0;
        nombre=nombre+".csv";
        this.Abrir(nombre);
        
        this.vector=new Vector();
        //this.vector.clear();//limpio el vector
        while ((sCadena = this.bufferArchivo.readLine())!=null) { //lee hasta final del archivo
                celdas=sCadena.split(";");
                
                this.vector.add(new Presupuesto( Integer.parseInt((String)celdas[0]),Integer.parseInt((String)celdas[1]),(String)celdas[2],nombre,contador));
                
        }
        this.cerrar();
        return this.vector;
    }

    public Vector getPresdag(String nombre) throws FileNotFoundException, IOException{
        String sCadena, celdas[];
        nombre=nombre+".csv";
        System.out.println(nombre);
        this.Abrir(nombre);
        this.vector=new Vector();
        while ((sCadena = this.bufferArchivo.readLine())!=null) { //lee hasta final del archivo
                celdas=sCadena.split(";");
                
                DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
                try{
                    this.vector.add(new Presdag( Integer.parseInt((String)celdas[0]),((String)celdas[1]),(String)celdas[2],Integer.parseInt((String)celdas[3]),(String)celdas[4],Integer.parseInt((String)celdas[5]),df.parse((String)celdas[6])   ));
                }catch(Exception e){

                }
        }
        this.cerrar();
        return this.vector;
    }
    
    private void Abrir(String nombre) throws FileNotFoundException{
        this.archivo = new FileReader(nombre);
        this.bufferArchivo = new BufferedReader(this.archivo);
    }
    
    public void cerrar() throws IOException{
        this.archivo.close();
    }

        
}

/*******************************/
public class Presupuesto {
    int año;
    int monto;
    String agencia;

    String archivo;
    int linea;


    public Presupuesto(int año,int monto,String agencia,String archivo,int linea){
        this.año=año;
        this.monto=monto;
        this.agencia=agencia;

        this.archivo=archivo;
        this.linea=linea;
    }

    public int obtenerAño(){
        return this.año;
    }
    public int obtenerMonto(){
        return this.monto;
    }
    public String obtenerAgencia(){
        return this.agencia;
    }
    public int obtenerLinea(){
        return this.linea;
    }
    public String obtenerArchivo(){
        return this.archivo;
    }

}
« Última modificación: 15 Noviembre 2009, 00:34 am por sevid » En línea

sevid

Desconectado Desconectado

Mensajes: 7


Ver Perfil
Re: ayuda plis, quebrando me el coco buscando por que esta mal
« Respuesta #3 en: 14 Noviembre 2009, 15:43 pm »

ME falto decir que me da este error

Validador.java:30: getPresupuestos() in alarcon_fierro.Archivo cannot be applied to (java.lang.String)
            this.presupuestos=this.archivo.getPresupuestos("Presupuestos");
En línea

Leyer


Desconectado Desconectado

Mensajes: 786


leyer@elhacker.net


Ver Perfil WWW
Re: ayuda plis, quebrando me el coco buscando por que esta mal
« Respuesta #4 en: 14 Noviembre 2009, 15:55 pm »

posiblemente estes tratanto de pasar un string invalido a integer o a la contraria el cual sakas del archivo presupuestos

Saludos.
« Última modificación: 14 Noviembre 2009, 15:59 pm por L-EYER » En línea

sevid

Desconectado Desconectado

Mensajes: 7


Ver Perfil
Re: ayuda plis, quebrando me el coco buscando por que esta mal
« Respuesta #5 en: 14 Noviembre 2009, 16:27 pm »

no, el programa lo hacia bien, me tiro error cuando le cambie  para q abriera el archivo que queria que abrira "Presupuestos.csv", (ahora le paso como argumento el nombre del archivo q quiero abrir(el que esta alli existe por siaca)

bueno, muchas gracias =.
En línea

Casidiablo
Desarrollador
Colaborador
***
Desconectado Desconectado

Mensajes: 2.919



Ver Perfil WWW
Re: ayuda plis, quebrando me el coco buscando por que esta mal
« Respuesta #6 en: 14 Noviembre 2009, 17:10 pm »

ME falto decir que me da este error

Validador.java:30: getPresupuestos() in alarcon_fierro.Archivo cannot be applied to (java.lang.String)
 this.presupuestos=this.archivo.getPresupuestos("Presupuestos");


Ese error es bastante claro... tienes declarado un método llamado getPresupuestos que NO recibe parámetros... pero le estás pasando un String.

¿ya lo resolviste?

En línea

Leyer


Desconectado Desconectado

Mensajes: 786


leyer@elhacker.net


Ver Perfil WWW
Re: ayuda plis, quebrando me el coco buscando por que esta mal
« Respuesta #7 en: 14 Noviembre 2009, 17:26 pm »

ME falto decir que me da este error

Validador.java:30: getPresupuestos() in alarcon_fierro.Archivo cannot be applied to (java.lang.String)
 this.presupuestos=this.archivo.getPresupuestos("Presupuestos");


Ese error es bastante claro... tienes declarado un método llamado getPresupuestos que NO recibe parámetros... pero le estás pasando un String.
¿ya lo resolviste?

Si le recibe fijate public Vector getPresupuestos(String nombre) throws FileNotFoundException, IOException{
pero al parecer ya lo resolvio

Saludos.
En línea

sevid

Desconectado Desconectado

Mensajes: 7


Ver Perfil
Re: ayuda plis, quebrando me el coco buscando por que esta mal
« Respuesta #8 en: 14 Noviembre 2009, 23:54 pm »

no lo he resuelto, no entendi eso ultimo, podrias explicarmelo plis?
En línea

-Ramc-


Desconectado Desconectado

Mensajes: 495



Ver Perfil
Re: ayuda plis, quebrando me el coco buscando por que esta mal
« Respuesta #9 en: 15 Noviembre 2009, 00:01 am »

Debugealo, ¿qué se supone que es alarcon_fierro?

Ponlo entre etiquetas code que no me dan ganas ni de leerlo. :xD
En línea


Shhh... be vewy, vewy, quiet!  I'm hunting wabbits...
LA PANDILLA MAS GRANDE DE MI CIUDAD, SE LLAMA POLICIA NACIONAL.
Páginas: [1] 2 Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines