2016-12-27 17:29:40 +00:00
|
|
|
import java.util.LinkedList;
|
2016-12-28 11:10:09 +00:00
|
|
|
import java.util.ListIterator;
|
2016-12-27 17:29:40 +00:00
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
public class LibreriaCanzoni{
|
|
|
|
|
|
|
|
public LibreriaCanzoni(Scanner sc){
|
|
|
|
lib = new LinkedList<Canzone>();
|
|
|
|
Canzone temp=Canzone.read(sc);
|
|
|
|
while(temp!=null){
|
|
|
|
lib.addLast(temp);
|
|
|
|
temp=Canzone.read(sc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-28 11:10:09 +00:00
|
|
|
public LibreriaCanzoni(LinkedList<Canzone> lib){
|
|
|
|
this.lib=lib;
|
|
|
|
}
|
|
|
|
|
2016-12-28 11:54:45 +00:00
|
|
|
public LinkedList<Canzone> getLib(){
|
|
|
|
return lib;
|
|
|
|
}
|
|
|
|
|
2016-12-28 11:10:09 +00:00
|
|
|
public LibreriaCanzoni filtroAutore(String autore){
|
|
|
|
LinkedList<Canzone> newLib = new LinkedList<Canzone>();
|
|
|
|
ListIterator<Canzone> iter = lib.listIterator();
|
|
|
|
while(iter.hasNext()){
|
|
|
|
Canzone temp=iter.next();
|
|
|
|
if(temp.getAutore().equals(autore))
|
|
|
|
newLib.addLast(temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new LibreriaCanzoni(newLib);
|
|
|
|
}
|
|
|
|
|
2016-12-28 11:54:45 +00:00
|
|
|
public LibreriaCanzoni filtroTitolo(String titolo){
|
2016-12-28 11:10:09 +00:00
|
|
|
LinkedList<Canzone> newLib = new LinkedList<Canzone>();
|
|
|
|
ListIterator<Canzone> iter = lib.listIterator();
|
|
|
|
while(iter.hasNext()){
|
|
|
|
Canzone temp=iter.next();
|
|
|
|
if(temp.getAutore().equals(titolo))
|
|
|
|
newLib.addLast(temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new LibreriaCanzoni(newLib);
|
|
|
|
}
|
|
|
|
|
2016-12-28 11:54:45 +00:00
|
|
|
public LibreriaCanzoni filtroAlbum(String album){
|
2016-12-28 11:10:09 +00:00
|
|
|
LinkedList<Canzone> newLib = new LinkedList<Canzone>();
|
|
|
|
ListIterator<Canzone> iter = lib.listIterator();
|
|
|
|
while(iter.hasNext()){
|
|
|
|
Canzone temp=iter.next();
|
|
|
|
if(temp.getAutore().equals(album))
|
|
|
|
newLib.addLast(temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new LibreriaCanzoni(newLib);
|
|
|
|
}
|
|
|
|
|
2016-12-27 17:29:40 +00:00
|
|
|
private LinkedList<Canzone> lib;
|
|
|
|
}
|