I have a question with an exercise that says: Create a Book class with loan, return and toString methods.
I want the vector to grow as the number of books grows, but in codigo.length
, codigo
appears as not being initialized. What am I doing wrong? Can someone help? Thanks!
private String titulo;
private String autor;
private String genero;
private static int codigo;
private static int stock=0;
public Libro(String titulo, String autor, String genero, int codigo, int stock){
this.titulo=titulo;
generaCodigo();
this.autor=autor;
this.genero=genero;
}
public Libro(String titulo){
//El genera codigo me da error, me dice que cree un objeto
this("titulo", "desconocido", "a confirmar", generaCodigo(), 0);
}
public static void generaCodigo (){
//Acá me sale un error como que la variable codigo, en codigo.length no fue inicializada
int [] codigo = new int [codigo.length];
for(int i=0; i>=codigo.length; i++){
codigo[i]=i;
}
stock+=1
}