This commit is contained in:
orange 2016-12-28 12:54:45 +01:00
parent ff2cab2baa
commit 5a3bf67e1c
4 changed files with 47 additions and 2 deletions

View File

@ -20,6 +20,10 @@ public class Canzone{
return album;
}
public String toString(){
return titolo+" "+autore+" "+album+".";
}
public static Canzone read(Scanner sc){
String titolo, autore, album;
if(!sc.hasNext()) return null;

View File

@ -17,6 +17,10 @@ public class LibreriaCanzoni{
this.lib=lib;
}
public LinkedList<Canzone> getLib(){
return lib;
}
public LibreriaCanzoni filtroAutore(String autore){
LinkedList<Canzone> newLib = new LinkedList<Canzone>();
ListIterator<Canzone> iter = lib.listIterator();

17
src/Radio/Test.java Normal file
View File

@ -0,0 +1,17 @@
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Scanner;
import java.io.File;
public class Test{
public static void main(String [] args) throws Exception{
Scanner sc = new Scanner(new File("lib.dat"));
LibreriaCanzoni radio=new LibreriaCanzoni(sc);
ListIterator<Canzone> iter = radio.filtroAutore("Green Day").getLib().listIterator();
while(iter.hasNext()){
System.out.println(iter.next().toString());
}
}
}

20
src/Radio/lib.dat Normal file
View File

@ -0,0 +1,20 @@
Secchio
Pop x
Lesbianitj
#
Minority
Green Day
International Superhits
#
21 Guns
Green Day
21 Guns
#
Sparami
Pop x
Lesbianitj
#
Melons
Pop x
Lesbianitj
#