-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRH.java
More file actions
99 lines (82 loc) · 2.01 KB
/
RH.java
File metadata and controls
99 lines (82 loc) · 2.01 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
public class RH {
private Pessoa[] pessoas;
private int pessoasRegistradas;
public RH(int numeroPessoas) {
pessoas = new Pessoa[numeroPessoas];
pessoasRegistradas = 0;
}
public Pessoa consultarPessoa(int cpf){
for (int i = 0; i < pessoas.length; i++) {
if(pessoas[i].getCpf()==cpf){
return pessoas[i];
}
}
return null;
}
public void excluirPessoa(int cpf){
for (int i = 0; i < pessoas.length; i++) {
if(pessoas[i].getCpf()==cpf){
pessoas[i]=null;
for(int j = i; j<pessoasRegistradas-i; j++){
pessoas[j]=pessoas[j+1];
}
break;
}
}
}
public void resgistrarPessoa(String nome, int cpf, int idade, int numEventos) {
if (pessoasRegistradas < pessoas.length) {
pessoas[pessoasRegistradas] = new Pessoa(nome, cpf, idade, numEventos);
pessoasRegistradas++;
}
}
public int ConsultaNumPessoas(Evento evento) {
int total = 0;
for (Pessoa p : pessoas) {
for (int i = 0; i < p.getEventosRegistrados(); i++) {
if (p.getEventos()[i].equals(evento)) {
total++;
break;
}
}
}
return total;
}
public int ConsultaNumPessoas(int data[]) {
int total = 0;
for (Pessoa p : pessoas) {
for (int i = 0; i < p.getEventosRegistrados(); i++) {
if (p.getEventos()[i].equals(data)) {
total++;
break;
}
}
}
return total;
}
public boolean PessoaEmEvento(String nomeP, String nomeE) {
boolean existe = false;
for (Pessoa p : pessoas) {
if (p.getNome().equals(nomeP))
for (Evento event : p.getEventos()) {
if (event.getNome().equals(nomeE)) {
existe = true;
break;
}
}
}
return existe;
}
public Pessoa[] getPessoas() {
return pessoas;
}
public void setPessoas(Pessoa[] pessoas) {
this.pessoas = pessoas;
}
public int getPessoasRegistradas() {
return pessoasRegistradas;
}
public void setPessoasRegistradas(int pessoasRegistradas) {
this.pessoasRegistradas = pessoasRegistradas;
}
}