-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActivity.java
65 lines (43 loc) · 1.24 KB
/
Activity.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
package sports;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class Activity {
private String name;
private Set<Category> categorie = new HashSet<>();
private Set<Product> prodotti = new HashSet<>();
public Activity(String s) {
this.name=s;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void addCategory(Category c) {
categorie.add(c);
}
public List<String> getCategories(){
List<String> l = new ArrayList<>();
if(categorie.size()==0)
return l;
return categorie.stream().map(Category::getName)
.sorted((s,q)->s.compareTo(q))
.collect(Collectors.toList());
}
public void addProduct(Product s) {
prodotti.add(s);
}
public List<String> getProducts(){
return prodotti.stream().map(Product::getName)
.sorted((s,q)->s.compareTo(q))
.collect(Collectors.toList());
}
//_-------------------------------------------------------
private List<String> getRatingList(){
return prodotti.stream().flatMap(p->p.getRatings().stream()).collect(Collectors.toList());
}
}