2016-12-27 17:29:40 +00:00
|
|
|
import java.util.Scanner;
|
|
|
|
|
2016-12-23 11:49:18 +00:00
|
|
|
public class Canzone{
|
|
|
|
|
2016-12-27 17:29:40 +00:00
|
|
|
public Canzone(String titolo, String autore, String album){
|
|
|
|
this.titolo=titolo;
|
|
|
|
this.album=album;
|
|
|
|
this.autore=autore;
|
|
|
|
}
|
|
|
|
|
2016-12-23 11:49:18 +00:00
|
|
|
public String getTitolo(){
|
|
|
|
return titolo;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getAutore(){
|
|
|
|
return autore;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getAulbum(){
|
|
|
|
return album;
|
|
|
|
}
|
|
|
|
|
2016-12-28 11:54:45 +00:00
|
|
|
public String toString(){
|
|
|
|
return titolo+" "+autore+" "+album+".";
|
|
|
|
}
|
|
|
|
|
2016-12-27 17:29:40 +00:00
|
|
|
public static Canzone read(Scanner sc){
|
|
|
|
String titolo, autore, album;
|
|
|
|
if(!sc.hasNext()) return null;
|
|
|
|
titolo=sc.nextLine();
|
|
|
|
if(!sc.hasNext()) return null;
|
|
|
|
autore=sc.nextLine();
|
|
|
|
if(!sc.hasNext()) return null;
|
|
|
|
album=sc.nextLine();
|
|
|
|
if(!sc.hasNext()) return null;
|
|
|
|
sc.nextLine();
|
|
|
|
|
|
|
|
return new Canzone(titolo, autore, album);
|
|
|
|
}
|
|
|
|
|
2016-12-23 11:49:18 +00:00
|
|
|
private String titolo;
|
|
|
|
private String autore;
|
|
|
|
private String album;
|
|
|
|
}
|