Without a context about the problem, it is difficult to say precisely.
But just looking at the code, I understand that at the time of authentication you will perform a comparison between the Manager values and values that came from the parameters.
Therefore, login
:
//novo método, recebendo dois params
public boolean autentica(String login, int senha) {
//implementacao omitida
}
Just like the password, already in Gerente
:
private int senha;
It should instead be a private field of Gerente
. So:
private String login;
private int senha;
This is because login
and senha
become to Gerente
.
Then we would have something like this, using the above code:
Gerente gerente = new Gerente();
gerente.setSenha("senha");
gerente.setLogin("login");
boolen loginValido = gerente.autenticar("outroLogin", "outraSenha");
Or, better yet, without sets
and using constructor:
Gerente gerente = new Gerente("login", "senha");
boolen loginValido = gerente.autenticar("outroLogin", "outraSenha");
If you want to evolve this model, usually login
and senha
are associated with Usuario
. In this way, it would be interesting that Gerente
had a Usuario
with login and password.