-
Notifications
You must be signed in to change notification settings - Fork 0
/
Filter.java
69 lines (62 loc) · 1.81 KB
/
Filter.java
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
import java.util.HashSet;
public class Filter {
HashSet<Node> Fiction (HashSet<Node> root){
HashSet<Node> fiction= new HashSet<>();
for (Node node:root){
if(node.getGenre().equals("Fiction")){
fiction.add(node);
}
}
return fiction;
}
HashSet<Node> NonFiction (HashSet<Node> root){
HashSet<Node> Nonfiction= new HashSet<>();
for (Node node:root){
if(node.getGenre().equals("Non Fiction")){
Nonfiction.add(node);
}
}
return Nonfiction;
}
HashSet<Node> Both(HashSet<Node> root) {
return root;
}
HashSet<Node> RatingFilter (HashSet<Node> root,double rating){
HashSet<Node> Rate= new HashSet<>();
int i=1;
for (Node node:root){
if(node.getUserRating()>=rating){
Rate.add(node);
i++;
}
}
return Rate;
}
HashSet<Node> SourceUrduBazar (HashSet<Node> root){
HashSet<Node> UB= new HashSet<>();
for(Node node: root){
if(node.getSource().equals("Urdu Bazar")){
UB.add(node);
}
}
return UB;
}
HashSet<Node> SourceAmazon (HashSet<Node> root){
HashSet<Node> Amazzon= new HashSet<>();
for(Node node: root){
if(node.getSource().equals("Amazon")){
Amazzon.add(node);
}
}
return Amazzon;
}
HashSet<Node> SourceZstore (HashSet<Node> root){
HashSet<Node> Zstore= new HashSet<>();
for(Node node: root){
if(node.getSource().equals("Zstore") ){
Zstore.add(node);
}
}
return Zstore;
}
}