ayuda plis, quebrando me el coco buscando por que esta mal

Iniciado por sevid, 14 Noviembre 2009, 15:32 PM

0 Miembros y 1 Visitante están viendo este tema.

sevid

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
 
          /*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"));
   }


}



Leyer

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

Saludos.

sevid

#2
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

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;
   }

}

sevid

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");

Leyer

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

Saludos.

sevid

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 =.

Casidiablo

Cita de: sevid 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");


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?


Leyer

Cita de: Casidiablo en 14 Noviembre 2009, 17:10 PM
Cita de: sevid 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");


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.

sevid

no lo he resuelto, no entendi eso ultimo, podrias explicarmelo plis?

-Ramc-

Debugealo, ¿qué se supone que es alarcon_fierro?

Ponlo entre etiquetas code que no me dan ganas ni de leerlo. :xD

Shhh... be vewy, vewy, quiet!  I'm hunting wabbits...
LA PANDILLA MAS GRANDE DE MI CIUDAD, SE LLAMA POLICIA NACIONAL.