0
The goal is to make the program accept only numbers in the method numero() (cannot accept if it is letter, point, question mark, etc).
Already in the method usuario(), letter only (cannot accept numbers, point, question mark, etc).
public void numero() {
System.out.println("Digite o número da conta: ");
this.setNumeroConta(sc.nextInt());
sc.nextLine();
if (this.getNumeroConta() >= 0) {
System.out.println("SUCESSO_NA_OPERÇÃO NUMERO_DA_CONTA");
}
} else {
System.out.println("Somente números");
}
}
public void usuario() {
System.out.println("Digite o nome de usuário: ");
this.setDono(sc.nextLine());
if (this.getDono() != null) {
System.out.println("SUCESSO_NA_OPERÇÃO NOME_DO_USUARIO");
}
} else{
System.out.println("Somente letras");
}
}
Take a look at this question and its answer: https://answall.com/q/42351/132
– Victor Stafusa
I did not understand, the statement seemed to me very confusing. Would it be as examples of what should be accepted/refused by these methods? And as you call them in the main program?
– Jefferson Quesado