-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResearch.java
More file actions
40 lines (33 loc) · 1.17 KB
/
Research.java
File metadata and controls
40 lines (33 loc) · 1.17 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
package Work02.Unit01;
import java.util.ArrayList;
import java.util.Scanner;
public class Research {
ArrayList<String> result = new ArrayList<>();
ArrayList<Node> tree;
ArrayList<String> resultAge = new ArrayList<>();
public Research(Tree geoTree) {
tree = geoTree.getTree();
}
// метод поиска связи: родитель - ребенок, жена-муж
public ArrayList<String> spend(Person p, Relationship re) {
for (Node t : tree) {
if (t.p1.fullName == p.fullName && t.re == re) {
result.add(t.p2.fullName);
}
}
return result;
}
// метод поиска по возрасту
public ArrayList<String> searchAge() {
System.out.print("Введите ограничение по возрасту: ");
Scanner in = new Scanner(System.in);
int age = in.nextInt();
System.out.println("Люди, младше: " + age + ":");
for (Node t : tree) {
if (t.p1.age <= age && !resultAge.contains(t.p1.fullName)) {
resultAge.add(t.p1.fullName);
}
}
return resultAge;
}
}