-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathPeople.java
More file actions
58 lines (44 loc) · 1.26 KB
/
People.java
File metadata and controls
58 lines (44 loc) · 1.26 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
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> {
List<E> personList;
public People(){
personList= new ArrayList<E>();
}
public void addPerson(E person){
personList.add(person);
}
public Person findById(Long id){
Person personFinder = null;
for (int i = 0; i < personList.size(); i++) {
if (personList.get(i).getId()==id){
personFinder = personList.get(i);
}
}return personFinder;
}
public Boolean contains(E person){
return personList.contains(person);
}
public void removePerson(E person){
personList.remove(person);
}
public void removeById(Long id) {
for (int i = 0; i < personList.size(); i++) {
if (personList.get(i).getId() == id) {
personList.remove(personList.get(i));
}
}
}
public void removeAll(){
personList.removeAll(personList);
}
public int count(){
return personList.size();
}
public abstract E[] toArray();
public Iterator<E> iterator() {
return personList.iterator();
}
}