-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdvancedControl.java
More file actions
78 lines (63 loc) · 2.06 KB
/
AdvancedControl.java
File metadata and controls
78 lines (63 loc) · 2.06 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class AdvancedControl {
private SongLibrary songlib;
private Sorter sorter;
private Finder finder;
private Optional<Song> singleQuery;
private List<Song> currentUserQuery;
private List<Song> libraryStoring;
private int headStoring;
public AdvancedControl(SongLibrary sl){
this.songlib = sl;
this.sorter = new Sorter(sl);
this.finder = new Finder(sl);
this.currentUserQuery = new ArrayList<>();
this.headStoring = 0;
this.libraryStoring = new ArrayList<>();
}
public void sortByTitle(){
sorter.sortByTitleName();
}
public void sortByAuthor(){
sorter.sortByAuthorName();
}
public void sortByYear(){
sorter.sortByPublishingYear();
}
//Finders
public void findLongest(){
clearQuery();
this.singleQuery = finder.longestSongFinder();
if(singleQuery.isPresent()){
this.songlib.modifyWhereInList(songlib.getMyLibrary().indexOf(singleQuery.get()));
this.currentUserQuery.add(singleQuery.get());
}
}
public void findByWhom(String authr){
clearQuery();
this.libraryStoring = this.songlib.getMyLibrary();
this.headStoring = this.songlib.getWhereInList();
this.currentUserQuery = finder.songsByWhom(authr);
this.songlib.modifyPlaylist(currentUserQuery);
this.songlib.modifyWhereInList(0);
}
public void findAllAuthors(){
System.out.println("All authors in playlist: "+ finder.songAuthors());
}
public void backToLibrary(){
this.songlib.modifyPlaylist(libraryStoring);
this.songlib.modifyWhereInList(headStoring);
}
public void modifySongLib(SongLibrary sl){
this.songlib = sl;
sorter.changeLibrary(sl);
finder.changeLibrary(sl);
}
public void clearQuery(){
this.headStoring = 0;
if(!(currentUserQuery.isEmpty()))
this.currentUserQuery.clear();
}
}