1
I have a mistake in one of case
s of switch
, the mistake is this:
I’m doing a CRUD from a library, so when you see the code, maybe you think something’s weird:
I made some switch
with only 1 option, as each option leads to a different menu
@Override
public int Menu(int menu) {
int opc=0;
System.out.println("-======MENU======-\n\n" +
"1. Cadastrar\n" +
"2. Editar\n" +
"3. Pesquisar\n" +
"4. Listar\n" +
"5. Excluir\n" +
"6. Excluir tudo\n" +
"7. Sair");
return opc;
}
The first option goes to the registration menu, the second goes to the edit menu... so I thought I’d make a switch
with an option for each menu.
I will make the code available to you on my Github, because it is too long to put here, the error is in the Main class, more specifically in line 198, where it has written:
The mistake happens right here:
case 2 : {
Biblioteca.MenuEditar(opc);
}
You can only sign the method
Biblioteca.MenuEditar
? It seems that you expect a boolean in the signature, but is passing an integer– Jefferson Quesado
I swear I tried to read your code, but it is not beautiful, which has just influenced the readability. I believe that, for each case of
switch
, it would be better to delegate to a function/method that deals with the desired. For example, case 1 calls the register function, which in turn would have aswitch
playing for methods ofcadastrarAutor
(case 1),cadastrarEditora
(case 2) etc– Jefferson Quesado
public int menuEditar(int menu);
– italo vinicius
Tries to compile with
javac
and shows us the errors that the compiler releases, we may have more tips– Jefferson Quesado