-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonitor.java
More file actions
86 lines (77 loc) · 2.31 KB
/
Monitor.java
File metadata and controls
86 lines (77 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
public class Monitor {
private String nome;
private String login;
private String senha;
private int matricula;
final boolean NiveldeAcesso=false; //o nivel de acesso do monitor é sempre negado(false).
public Monitor(){};
public Monitor (String Name,String Log,String Pass,int mat)
{
setNomeMonitor(Name);
setLogin(Log);
setSenha(Pass);
setMatricula(mat);
}
//métodos get e sets.
public String getNomeMonitor() {
return nome;
}
public void setNomeMonitor(String Name)
{
if(Name!= null && Name!= "\0")
this.nome = Name;
else
System.out.println("digite um nome válido");
}
public int matricula() {
return matricula;
}
public void setMatricula(int Mat)
{
int a = (int)(Math.log10(Mat)+1);//verifica se tem 10 digitos.
System.out.println(a);
if( Mat !=0 && a != 10 )
this.matricula=Mat;
else
System.out.println("digite um nome válido");
}
public String getLogin()
{
return login;
}
public void setLogin(String Log)
{
if(Log != null && Log != "\0")
this.login=Log;
else
System.out.println("digite um login válido");
}
public String getSenha()
{
return senha;
}
public void setSenha(String Password)
{
if(Password!= null && Password != "\0")
this.senha=Password;
else
System.out.println("digite uma senha válida");
}
public void Login( String TentativaLogin,String TentativaSenha)
{
String LoginAtual=getLogin(); //salva o login e a senha atuais em duas variáveis locais.
String SenhaAtual=getSenha();
setLogin(TentativaLogin); //chama os métodos set e get para verificar se os dados são válidos.
setSenha(TentativaSenha);
if(TentativaLogin==LoginAtual && TentativaSenha == SenhaAtual ) //verifica se o login e a senha inseridos são iguais as senhas atuais.
{
System.out.println("Login relalizado com sucesso"); //se for igual,o login é realizado.
}
else
{
System.out.println("Login ou senha incorretos"); //se nao for igual,o login é negado e volta para a senha e login anteriores.
login=LoginAtual;
senha=SenhaAtual;
}
}
}