0
I’m a beginner in Java, and I’m having an error in an Edit class method to remove the publisher. The method to remove an author works perfectly with the same logic, already in the remove editor method it gives this error:
Follows the code:
Library class, containing the methods to remove Author and Publisher
public void removerAutorAnterior(Autor codigo) {
autores.remove(codigo);
}
public void removerEditoraAnterior(Editora codigo) {
editora.remove(codigo);
}
Edit class
case 1:{
Autor AtorAnterior=biblioteca.pesquisarAutor(codigo);
System.out.println("Digite o código do autor que deseja editar:");
AtorAnterior.setCodigo(scannerNumerico.nextInt());
if(AtorAnterior==null){
System.out.println("Error: autor não encontrado");
}
else{
System.out.println("Autor encontrado:"+AtorAnterior.getNome());
Autor Autornovo= new Autor();
System.out.println("Digite um novo nome:");
Autornovo.setNome(scannerString.nextLine());
System.out.println("Digite um novo email:");
Autornovo.setEmail(scannerString.nextLine());
biblioteca.removerAutorAnterior(AtorAnterior); **irá remover o autor anterior**
biblioteca.cadastarAutor(Autornovo); **irá cadastrar o novo autor**
}
break;
}
That’s where the error in the method lies:removerEditoraAnterior(Editoraanterior):
//Editar Editora
case 2:{
Editora EditoraAnterior=biblioteca.pesquisarEditora(codigo);
System.out.println("Digite o código da editora que deseja editar:");
EditoraAnterior.setCodigo(scannerNumerico.nextInt());
if( EditoraAnterior==null){
System.out.println("Error: Editora não encontrada");
}
else{
System.out.println("Editora encontrada:"+ EditoraAnterior.getNome());
Editora EditoraNova= new Editora();
System.out.println("Digite os novos dados:\n");
System.out.println("Digite novo nome:");
EditoraNova.setNome(scannerNumerico.nextLine());
System.out.println("Digite o novo cnpj");
EditoraNova.setCnpj(scannerNumerico.nextInt());
biblioteca.removerEditoraAnterior(EditoraAnterior);
biblioteca.cadastrarEditora(EditoraNova);
break;
}
}
I’m beginning to question your IDE’s sanity, given the context of problems it has already presented. Clear the area and have a clean build
– Jefferson Quesado
I agree with the above friend, I think his eclipse is a bit buggy, or there is another project in the eclipse that is conflicting with this one. Already checked the build path?
– Henrique Santiago
Man, you don’t put keys in after one
case
._.– igventurelli
Friend always used keys after cases, and never gave any problem , I believe that the error ñ is because of this
– italo vinicius
I’m a beginner in Java/Eclipse, I don’t know how to clean the area , build, check build Patch or something like that yet ._.
– italo vinicius