-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathPeople.java
More file actions
60 lines (42 loc) · 1.14 KB
/
People.java
File metadata and controls
60 lines (42 loc) · 1.14 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
package io.zipcoder.interfaces;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public abstract class People<E extends Person> implements Iterable<E> {
public List<E> personList = new ArrayList<E>();
public void addPerson(E person) {
personList.add(person);
}
public E findById(Long id) {
for (E person : personList) {
if (person.getId() == id)
return person;
}
return null;
}
public boolean containsPerson(E person) {
if (personList.contains(person)) {
return true;
}
return false;
}
public void removePerson(E person) {
personList.remove(person);
}
public void removeById(Long id) {
for (E person : personList) {
if (person.getId() == id)
personList.remove(person);
}
}
public void removeAllPeople() {
personList.clear();
}
public Integer count() {
return personList.size();
}
public abstract E[] toArray();
public Iterator<E> iterator() {
return personList.iterator();
}
}